diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 00000000..58fbfe09 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,24 @@ +name: Setup +description: Setup Node.js and install dependencies +inputs: + node-version: + description: Node version + required: false + default: '24' + +runs: + using: composite + steps: + - name: Install pnpm + uses: pnpm/action-setup@v4.1.0 + + - name: Setup Node.js ${{ inputs.node-version }} + uses: actions/setup-node@v4.4.0 + with: + node-version: ${{ inputs.node-version }} + registry-url: 'https://registry.npmjs.org' + cache: pnpm + + - name: Install dependencies + run: pnpm install + shell: bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..c2f45025 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,51 @@ +name: Release & Publish to NPM & GitHub +on: + workflow_dispatch: + inputs: + increment: + description: 'Increment type: major, minor, patch, pre...' + required: true + type: choice + options: + - patch + - minor + - major + - prepatch + - preminor + - premajor + default: patch + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + with: + fetch-depth: 0 + + - name: Setup + uses: ./.github/actions/setup + + - name: Import GPG key + id: import-gpg + uses: crazy-max/ghaction-import-gpg@v6.3.0 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + git_user_signingkey: true + git_commit_gpgsign: true + + - run: pnpm run release --increment ${{github.event.inputs.increment}} --ci + env: + # For release-it + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_CONFIG_PROVENANCE: true + # For lerna-changelog + IGNORE_PEER_DEPENDENCIES: release-it + GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }} + +permissions: + contents: write + id-token: write diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d530f1ad..908e08b1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,58 +16,60 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - node: [18] + node: [22, 24] steps: - name: Checkout - uses: actions/checkout@v3.0.2 - - name: Setup Node.js ${{ matrix.node }} - uses: actions/setup-node@v3.5.0 + uses: actions/checkout@v4.2.2 + - name: Setup + uses: ./.github/actions/setup with: node-version: ${{ matrix.node }} - - uses: pnpm/action-setup@v2.2.2 - with: - version: 7.x.x - run_install: true - name: Test run: pnpm test:coverage - name: Upload code coverage - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v5 lint: runs-on: ubuntu-latest name: Lint source code steps: - name: Checkout - uses: actions/checkout@v3.0.2 - - name: Setup Node.js - uses: actions/setup-node@v3.5.0 - - uses: pnpm/action-setup@v2.2.2 - with: - version: 7.x.x - run_install: true + uses: actions/checkout@v4.2.2 + - name: Setup + uses: ./.github/actions/setup - name: Lint run: pnpm lint + publish: + runs-on: ubuntu-latest + name: Publish test build to pkg.pr.new + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + - name: Setup + uses: ./.github/actions/setup + + - name: Build + run: pnpm build + - name: Publish + run: pnpx pkg-pr-new publish + test-examples: runs-on: ubuntu-latest name: Test build of example projects steps: - name: Checkout unplugin-fluent-vue - uses: actions/checkout@v3.0.2 + uses: actions/checkout@v4.2.2 - name: Checkout examples - uses: actions/checkout@v3.0.2 + uses: actions/checkout@v4.2.2 with: repository: fluent-vue/examples path: examples - - name: Setup Node.js - uses: actions/setup-node@v3.5.0 - - uses: pnpm/action-setup@v2.2.2 - with: - version: 7.x.x - run_install: true + - name: Setup + uses: ./.github/actions/setup - name: Test - run: node scripts/build-examples.mjs + run: node scripts/build-examples.js diff --git a/.husky/pre-commit b/.husky/pre-commit index e0b5a3b9..cb2c84d5 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,5 +1 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - pnpm lint-staged - diff --git a/.release-it.json b/.release-it.json index 510aea89..ba0e5541 100644 --- a/.release-it.json +++ b/.release-it.json @@ -1,6 +1,6 @@ { "hooks": { - "before:init": ["pnpm lint", "pnpm test -- --run"], + "before:init": ["pnpm lint", "pnpm test --run"], "after:bump": "pnpm build" }, "github": { @@ -8,7 +8,8 @@ }, "plugins": { "@release-it-plugins/lerna-changelog": { - "infile": "CHANGELOG.md" + "infile": "CHANGELOG.md", + "launchEditor": false } } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 11add154..7937e33b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,80 @@ + + + + + + + + +## 1.4.1 (2025-06-01) + +#### :star: New Features +* [#128](https://github.com/fluent-vue/unplugin-fluent-vue/pull/128) Set up release workflow and NPM provenance ([@Demivan](https://github.com/Demivan)) + +#### Committers: 1 +- Ivan Demchuk ([@Demivan](https://github.com/Demivan)) + +## 1.4.0 (2025-02-24) + +#### :star: New Features +* [#107](https://github.com/fluent-vue/unplugin-fluent-vue/pull/107) Add an option to parse FTL during build ([@Demivan](https://github.com/Demivan)) + +#### Committers: 1 +- Ivan Demchuk ([@Demivan](https://github.com/Demivan)) + +## 1.3.2 (2024-11-13) + +#### :bug: Bug Fixes +* [#103](https://github.com/fluent-vue/unplugin-fluent-vue/pull/103) Add sourcemap support to SFCFluentPlugin ([@Demivan](https://github.com/Demivan)) + +#### Committers: 1 +- Ivan Demchuk ([@Demivan](https://github.com/Demivan)) + +## 1.3.1 (2024-09-12) + +#### :bug: Bug Fixes +* [#97](https://github.com/fluent-vue/unplugin-fluent-vue/pull/97) Make @nuxt/kit dependency optional ([@Demivan](https://github.com/Demivan)) + +#### Committers: 1 +- Ivan Demchuk ([@Demivan](https://github.com/Demivan)) + +## 1.3.0 (2024-04-05) + +#### :star: New Features +* [#84](https://github.com/fluent-vue/unplugin-fluent-vue/pull/84) Add Nuxt module ([@Demivan](https://github.com/Demivan)) + +#### Committers: 1 +- Ivan Demchuk ([@Demivan](https://github.com/Demivan)) + +## 1.2.0 (2024-03-05) + +#### :star: New Features +* [#55](https://github.com/fluent-vue/unplugin-fluent-vue/pull/55) Mark ftl imports side-effect free ([@Demivan](https://github.com/Demivan)) + +#### Committers: 1 +- Ivan Demchuk ([@Demivan](https://github.com/Demivan)) + +## 1.1.4 (2023-03-23) + +## 1.1.3 (2023-03-22) + +#### :bug: Bug Fixes +* [#43](https://github.com/fluent-vue/unplugin-fluent-vue/pull/43) Fix HMR code not being treeshaken ([@Demivan](https://github.com/Demivan)) + +#### Committers: 1 +- Ivan Demchuk ([@Demivan](https://github.com/Demivan)) + +## 1.1.2 (2022-11-09) + +#### :bug: Bug Fixes +* [#31](https://github.com/fluent-vue/unplugin-fluent-vue/pull/31) Do not transform file if there are no translations ([@Demivan](https://github.com/Demivan)) + +#### Committers: 1 +- Ivan Demchuk ([@Demivan](https://github.com/Demivan)) + ## 1.1.1 (2022-10-05) #### :star: New Features diff --git a/README.md b/README.md index bb986edf..dbb4d2c3 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@
-
+
@@ -31,11 +31,11 @@ npm install unplugin-fluent-vue --save-dev
```ts
// vite.config.js
-import { defineConfig } from 'vite'
import {
ExternalFluentPlugin,
SFCFluentPlugin,
} from 'unplugin-fluent-vue/vite'
+import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
@@ -44,12 +44,14 @@ export default defineConfig({
SFCFluentPlugin({ // define messages in SFCs
blockType: 'fluent', // default 'fluent' - name of the block in SFCs
checkSyntax: true, // default true - whether to check syntax of the messages
+ parseFtl: false, // default false - whether to parse ftl files during build
}),
ExternalFluentPlugin({ // define messages in external ftl files
baseDir: path.resolve('src'), // required - base directory for Vue files
ftlDir: path.resolve('src/locales'), // required - directory with ftl files
locales: ['en', 'da'], // required - list of locales
checkSyntax: true, // default true - whether to check syntax of the messages
+ parseFtl: false, // default false - whether to parse ftl files during build
}),
],
})
diff --git a/__tests__/fixtures/components/external.setup.vue b/__tests__/fixtures/components/external.setup.vue
index 1914ae2a..a4f8cd10 100644
--- a/__tests__/fixtures/components/external.setup.vue
+++ b/__tests__/fixtures/components/external.setup.vue
@@ -1,10 +1,10 @@
+
+