Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Extension package and release

on:
pull_request:
push:
branches: [main]
workflow_dispatch:
inputs:
destination:
description: Publishing destination (artifact only does not publish)
required: true
type: choice
default: artifact
options:
- artifact
- open-vsx
- vscode-marketplace
- both

permissions:
contents: read

jobs:
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- name: Compile, lint and test
run: npm test
- name: Package extension
run: |
mkdir -p dist
npx --no-install vsce package --out dist/ai-localizer.vsix
sha256sum dist/ai-localizer.vsix > dist/ai-localizer.vsix.sha256
echo "Packaged venmail.ai-localizer $(node -p 'require("./package.json").version')" >> "$GITHUB_STEP_SUMMARY"
- name: Upload VSIX artifact
uses: actions/upload-artifact@v4
with:
name: localizer-vsix
path: |
dist/ai-localizer.vsix
dist/ai-localizer.vsix.sha256
if-no-files-found: error

publish:
if: github.event_name == 'workflow_dispatch' && inputs.destination != 'artifact'
needs: package
runs-on: ubuntu-latest
concurrency:
group: extension-publish
cancel-in-progress: false
steps:
- name: Require the main branch
if: github.ref != 'refs/heads/main'
run: |
echo 'Publication is allowed only from main.' >&2
exit 1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- uses: actions/download-artifact@v4
with:
name: localizer-vsix
path: dist
- name: Verify packaged artifact
run: sha256sum --check dist/ai-localizer.vsix.sha256
- name: Check publishing credentials
env:
DESTINATION: ${{ inputs.destination }}
OVSX_PAT: ${{ secrets.OVSX_PAT }}
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: |
if [[ "$DESTINATION" == 'open-vsx' || "$DESTINATION" == 'both' ]]; then
[[ -n "$OVSX_PAT" ]] || { echo 'Missing OVSX_PAT secret.' >&2; exit 1; }
fi
if [[ "$DESTINATION" == 'vscode-marketplace' || "$DESTINATION" == 'both' ]]; then
[[ -n "$VSCE_PAT" ]] || { echo 'Missing VSCE_PAT secret.' >&2; exit 1; }
fi
- name: Publish to Open VSX
if: inputs.destination == 'open-vsx' || inputs.destination == 'both'
env:
OVSX_PAT: ${{ secrets.OVSX_PAT }}
run: npx --yes ovsx@1.4.0 publish dist/ai-localizer.vsix
- name: Publish to Visual Studio Marketplace
if: inputs.destination == 'vscode-marketplace' || inputs.destination == 'both'
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: npx --no-install vsce publish --packagePath dist/ai-localizer.vsix
26 changes: 26 additions & 0 deletions dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,32 @@ When you are preparing a new release:
- Extension activates without errors.
- i18n commands and IntelliSense behave as expected.

## GitHub Actions packaging and publishing

The **Extension package and release** workflow builds and tests each pull
request and push to `main`. Download the `localizer-vsix` artifact from the
workflow run; it contains the VSIX and its SHA-256 checksum.

To publish, first merge the release changes and increment `package.json`'s
version for every new release. In GitHub, open **Actions → Extension package and
release → Run workflow**, select `main`, and choose `open-vsx`,
`vscode-marketplace`, or `both`. Choose `artifact` to build without publishing.
The workflow publishes the exact VSIX produced by its tested package job.

Configure repository Actions secrets before publishing:

- `OVSX_PAT`: an Open VSX token belonging to a publisher authorized for the
`venmail` namespace. Complete any required namespace ownership and publisher
agreement steps on Open VSX.
- `VSCE_PAT`: an Azure DevOps personal access token authorized to publish under
the `venmail` Visual Studio Marketplace publisher.

Both credentials are checked before either publication when `both` is chosen.
The registries publish independently: if the second publication fails, the
first may already be live. Resolve the error and rerun only the failed target.
Publishing is manual and restricted to `main`; ordinary PR and branch builds do
not publish. A marketplace will reject a version already published there.

---

## Project Structure (High Level)
Expand Down
73 changes: 67 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@
"pretest": "npm run compile && npm run lint",
"lint": "eslint src --ext ts",
"package": "npm run test && vsce package",
"test": "vitest run",
"test": "vitest run && node --test tests/ReportedIssues.regression.test.cjs",
"test:watch": "vitest",
"i18n:extract": "node ./scripts/extract-i18n.js",
"i18n:rewrite": "node ./scripts/replace-i18n.js",
Expand Down Expand Up @@ -508,6 +508,7 @@
"vitest": "^1.2.2"
},
"dependencies": {
"@babel/parser": "^7.29.14",
"magic-string": "^0.30.21",
"node-fetch": "^2.7.0",
"openai": "^4.0.0",
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/src/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,17 @@ async function run(parsed) {
const srcRoot = String(parsed.flags['src-root'] || defaults.srcRoot);
const localesDir = String(parsed.flags['locales-dir'] || defaults.localesDir);
const layout = String(parsed.flags.layout || defaults.layout);
if (layout !== 'single' && layout !== 'grouped') {
throw new Error('Invalid --layout: expected single or grouped');
}

const newBlock = {
sourceLocale,
defaultLocale: sourceLocale,
locales: finalLocales,
srcRoot,
localesDir,
localeLayout: layout,
layout,
};

const hasExisting = data.aiI18n && typeof data.aiI18n === 'object' && Object.keys(data.aiI18n).length > 0;
Expand Down
25 changes: 24 additions & 1 deletion packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ Most users should install the CLI. Install this package directly only if you wan
npm install @ai-localizer/core
```

Optional deps for legacy Babel-based JSX extraction fallback: `@babel/parser @babel/generator @babel/traverse @babel/types`. Default path uses `oxc-parser` (already bundled).
`@babel/parser` and `oxc-parser` are installed with the package. The legacy
Babel JSX backend additionally requires `@babel/generator`, `@babel/traverse`
and `@babel/types`.

## API

Expand Down Expand Up @@ -72,6 +74,27 @@ The pipeline reads `package.json#aiI18n` (or `composer.json#extra.aiI18n` for La
}
```

### Vue setup scripts

The default `replace` backend reuses a top-level `useI18n()` composer or its
`t` binding in `<script setup>`. When a component has no such binding, it
leaves script strings unchanged unless the project explicitly opts in:

```json
{
"aiI18n": {
"vueSetupTranslation": "vue-i18n-composition"
}
}
```

Use this setting only when the project uses Vue I18n's Composition API and has
configured it accordingly (for legacy-capable Vue I18n versions, this means
`createI18n({ legacy: false, ... })`). The rewriter then imports `useI18n` and
creates a collision-safe binding only in setup scripts that need one. It does
not configure or install Vue I18n. Existing composers and their scope/options
are preserved. See the [Vue I18n composition guide](https://vue-i18n.intlify.dev/guide/advanced/composition).

## License

Apache-2.0 © Chibueze Opata
18 changes: 12 additions & 6 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,20 @@
"node": ">=18"
},
"dependencies": {
"oxc-parser": "^0.89.0",
"magic-string": "^0.30.21"
"@babel/parser": "^7.29.14",
"magic-string": "^0.30.21",
"oxc-parser": "^0.89.0"
},
"peerDependenciesMeta": {
"@babel/parser": { "optional": true },
"@babel/generator": { "optional": true },
"@babel/traverse": { "optional": true },
"@babel/types": { "optional": true }
"@babel/generator": {
"optional": true
},
"@babel/traverse": {
"optional": true
},
"@babel/types": {
"optional": true
}
},
"publishConfig": {
"access": "public"
Expand Down
Loading
Loading