diff --git a/.changeset/thin-beds-sniff.md b/.changeset/thin-beds-sniff.md new file mode 100644 index 000000000..bde715464 --- /dev/null +++ b/.changeset/thin-beds-sniff.md @@ -0,0 +1,5 @@ +--- +"@aiou/neo": patch +--- + +pref should be original user-input diff --git a/packages/core/package.json b/packages/core/package.json index 81e6c6596..9bd55bfc7 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -102,7 +102,7 @@ "terminal-link": "^3.0.0", "typescript": "^5.6.3", "vitest": "^0.7.7", - "vitest-extra": "^0.0.4", + "vitest-extra": "^0.1.0", "write-yaml-file": "^5.0.0", "zen-observable": "^0.8.15" } diff --git a/packages/core/src/commands/run.ts b/packages/core/src/commands/run.ts index ba888b99b..e54f016ee 100644 --- a/packages/core/src/commands/run.ts +++ b/packages/core/src/commands/run.ts @@ -1,6 +1,5 @@ import path from 'node:path' -import parseWantedDependency from '@pnpm/parse-wanted-dependency' import fs from 'fs-extra' import Listr from 'listr' @@ -9,7 +8,7 @@ import { isYaml } from '../utils' import { debug } from '../utils/logger' import { runMario } from '../utils/mario' import { usage } from '../utils/show-usage' - +import { parseWantedPackage } from '../utils/find-pref-package' import type { CommonOptions } from '../interface' export type RunOptions = CommonOptions & { module?: string[] } @@ -33,9 +32,9 @@ export const run = async (alias: string, params: RunOptions) => { { title: `Download mario generator ${alias}`, task: async () => { - const result = parseWantedDependency(alias) - const response = await store.pm.request({ alias: result.alias, pref: result.pref }) - await store.pm.import(target, response) + const result = parseWantedPackage(alias) + const response = await store.pm.request({ alias: result.alias, pref: result.pref, latest: result.version === 'latest' }) + await store.pm.import(target, response, { latest: result.version === 'latest' }) return true }, }, diff --git a/packages/core/src/interface/index.ts b/packages/core/src/interface/index.ts index 124d7a013..d3e7ca10c 100644 --- a/packages/core/src/interface/index.ts +++ b/packages/core/src/interface/index.ts @@ -17,6 +17,10 @@ export interface Package extends PresetTemplate { version: string pref: string id: string + // will be selected in create command(inquirer.search-list), if duplicated in lockfile + // name will be uniq by Lockfile, create uniq name by makeUniqId, format: () + // however, package store in .neo-lock.yaml can be duplicated + name: string cached?: boolean // package from which preset preset?: string @@ -27,8 +31,17 @@ export interface Package extends PresetTemplate { } export interface LockFile { + // neo version version?: string + /** + * @description cached templates + * 1. once cmd-add with type=template, the template will be cached + * 2. once cmd-create from store(preset), the template will be cached + */ templates?: Record + /** + * @description presets + */ presets?: Record } diff --git a/packages/core/src/store/index.ts b/packages/core/src/store/index.ts index 02e9427e4..f33c756c8 100644 --- a/packages/core/src/store/index.ts +++ b/packages/core/src/store/index.ts @@ -72,8 +72,10 @@ const createStore = async (params: CommonOptions) => { return } const { id } = response.body + // templates pkgs maybe has same name, use id as key + // name and pref parsed from user-input await lockFile.updateTemplates({ - [params.name]: { + [id]: { name: params.name, version: response.body.manifest?.version, id, diff --git a/packages/core/src/utils/find-pref-package.ts b/packages/core/src/utils/find-pref-package.ts index 0dcf75394..25d2c9ae1 100644 --- a/packages/core/src/utils/find-pref-package.ts +++ b/packages/core/src/utils/find-pref-package.ts @@ -3,16 +3,19 @@ import { randomUUID } from 'node:crypto' import parseWantedDependency from '@pnpm/parse-wanted-dependency' import type { Package } from '../interface' +import { debug } from './logger' export const parseWantedPackage = (input: string) => { const { alias, pref } = parseWantedDependency(input) - return { + const options = { _name: alias || input, name: alias || input, alias, version: pref, - pref: alias || input, + pref: input, } + debug.utils('parse input %s into %O', input, options) + return options } /** diff --git a/packages/core/src/utils/logger.ts b/packages/core/src/utils/logger.ts index c13c48f89..4f20730c2 100644 --- a/packages/core/src/utils/logger.ts +++ b/packages/core/src/utils/logger.ts @@ -48,6 +48,7 @@ export const debug = { list: Debug('neo:cmd:list'), run: Debug('neo:cmd:run'), cleanup: Debug('neo:cmd:cleanup'), + utils: Debug('neo:utils'), } export default { diff --git a/packages/core/test/__snapshots__/store.test.ts.snap b/packages/core/test/__snapshots__/store.test.ts.snap index 74c256f9d..2160c2e3d 100644 --- a/packages/core/test/__snapshots__/store.test.ts.snap +++ b/packages/core/test/__snapshots__/store.test.ts.snap @@ -84,7 +84,7 @@ exports[`store > add preset 1`] = ` exports[`store > add template 1`] = ` { "templates": { - "bin": { + "@aiou/bin-template/4.0.0": { "id": "@aiou/bin-template/4.0.0", "name": "bin", "pref": "@aiou/bin-template", @@ -179,7 +179,7 @@ exports[`store > add(type=preset) 1`] = ` exports[`store > add(type=template) 1`] = ` { "templates": { - "@aiou/bin-template": { + "@aiou/bin-template/3.0.1": { "id": "@aiou/bin-template/3.0.1", "name": "@aiou/bin-template", "pref": "@aiou/bin-template@3.0.1", diff --git a/packages/core/test/cmd-add/__snapshots__/tpl-github.test.ts.snap b/packages/core/test/cmd-add/__snapshots__/tpl-github.test.ts.snap new file mode 100644 index 000000000..4be0aba5a --- /dev/null +++ b/packages/core/test/cmd-add/__snapshots__/tpl-github.test.ts.snap @@ -0,0 +1,15 @@ +// Vitest Snapshot v1 + +exports[`load template from github should work 1`] = ` +{ + "templates": { + "@aiou/actions-template/0.3.0": { + "id": "@aiou/actions-template/0.3.0", + "name": "https://github.com/neo-hack/actions-template", + "pref": "https://github.com/neo-hack/actions-template", + "version": "0.3.0", + }, + }, + "version": undefined, +} +`; diff --git a/packages/core/test/cmd-add/__snapshots__/tpl-npm.test.ts.snap b/packages/core/test/cmd-add/__snapshots__/tpl-npm.test.ts.snap index e8e5e9b7d..d76a3deea 100644 --- a/packages/core/test/cmd-add/__snapshots__/tpl-npm.test.ts.snap +++ b/packages/core/test/cmd-add/__snapshots__/tpl-npm.test.ts.snap @@ -3,7 +3,7 @@ exports[`load template from npm should work 1`] = ` { "templates": { - "@aiou/ts-lib-template": { + "@aiou/ts-lib-template/0.6.0": { "id": "@aiou/ts-lib-template/0.6.0", "name": "@aiou/ts-lib-template", "pref": "@aiou/ts-lib-template", diff --git a/packages/core/test/cmd-add/tpl-github.test.ts b/packages/core/test/cmd-add/tpl-github.test.ts index 67fa323b7..a97ebc27b 100644 --- a/packages/core/test/cmd-add/tpl-github.test.ts +++ b/packages/core/test/cmd-add/tpl-github.test.ts @@ -1,4 +1,9 @@ -import { clearLockFile } from '../helpers' +import { + clearLockFile, + execNeo, + randomStoreDir, + readLockFile, +} from '../helpers' afterEach(() => { clearLockFile() @@ -6,8 +11,16 @@ afterEach(() => { it.todo('fix timeout, load template from github should work') -// it('load template from github should work', async () => { -// const url = 'https://github.com/neo-hack/actions-template' -// await execNeo(['add', url, '--store-dir', storeDir]) -// expect(readLockFile()).toMatchSnapshot() -// }) +const storeDir: string = randomStoreDir() + +it('load template from github should work', async () => { + const url = 'https://github.com/neo-hack/actions-template' + await execNeo(['add', url, '--store-dir', storeDir], { + env: { + DEBUG: 'neo:*', + }, + stderr: 'inherit', + stdout: 'inherit', + }) + expect(await readLockFile(storeDir)).toMatchSnapshot() +}) diff --git a/packages/core/test/cmd-run/run.test.ts b/packages/core/test/cmd-run/run.test.ts index 42c7da0cd..ec4595d2b 100644 --- a/packages/core/test/cmd-run/run.test.ts +++ b/packages/core/test/cmd-run/run.test.ts @@ -26,10 +26,13 @@ describe('command run', () => { ) }) - it('run ci part should work', async () => { + it('run ci part should work #debug', async () => { fs.removeSync(r('test/fixtures/prepack-ci/output/.github')) - await execNeo(['run', '@aiou/generator-pnpm-ci', '--module', 'workflows'], { + await execNeo(['run', '@aiou/generator-pnpm-ci', '--module', 'workflows', '--store-dir', storeDir], { cwd: path.resolve(r('test/fixtures/prepack-ci/output')), + env: { + DEBUG: 'neo:*', + }, }) expect(r('test/fixtures/prepack-ci/output')).toMatchDir(r('test/fixtures/prepack-ci/expected')) }) diff --git a/packages/core/test/fixtures/prepack-ci/expected/.github/workflows/ci.yml b/packages/core/test/fixtures/prepack-ci/expected/.github/workflows/ci.yml index b116a1b01..4701374b9 100644 --- a/packages/core/test/fixtures/prepack-ci/expected/.github/workflows/ci.yml +++ b/packages/core/test/fixtures/prepack-ci/expected/.github/workflows/ci.yml @@ -12,11 +12,11 @@ jobs: strategy: matrix: - node-version: [16.x, 18.x] + node-version: [20.x, 22.x] steps: - name: Checkout code repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 - name: Use Node.js ${{ matrix.node-version }} @@ -24,7 +24,7 @@ jobs: with: node-version: ${{ matrix.node-version }} # Install pnpm depends on package.json packageManager field - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v4 name: Install pnpm id: pnpm-install with: @@ -33,7 +33,7 @@ jobs: shell: bash run: | echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - uses: actions/cache@v3 + - uses: actions/cache@v4 name: Setup pnpm cache with: path: ${{ env.STORE_PATH }} diff --git a/packages/core/test/fixtures/prepack-ci/expected/.github/workflows/release.yml b/packages/core/test/fixtures/prepack-ci/expected/.github/workflows/release.yml index b0eb40f14..0a4c8f33a 100644 --- a/packages/core/test/fixtures/prepack-ci/expected/.github/workflows/release.yml +++ b/packages/core/test/fixtures/prepack-ci/expected/.github/workflows/release.yml @@ -17,15 +17,15 @@ jobs: pull-requests: write steps: - name: Checkout code repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 20 # Install pnpm depends on package.json packageManager field - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v4 name: Install pnpm id: pnpm-install with: @@ -34,7 +34,7 @@ jobs: shell: bash run: | echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - uses: actions/cache@v3 + - uses: actions/cache@v4 name: Setup pnpm cache with: path: ${{ env.STORE_PATH }} diff --git a/packages/core/test/fixtures/prepack-ci/expected/.github/workflows/snapshot-release.yml b/packages/core/test/fixtures/prepack-ci/expected/.github/workflows/snapshot-release.yml index b9ce6f924..46a87140e 100644 --- a/packages/core/test/fixtures/prepack-ci/expected/.github/workflows/snapshot-release.yml +++ b/packages/core/test/fixtures/prepack-ci/expected/.github/workflows/snapshot-release.yml @@ -18,14 +18,14 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout code repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 - name: setup node.js uses: actions/setup-node@v4 with: - node-version: 18 - - uses: pnpm/action-setup@v2 + node-version: 20 + - uses: pnpm/action-setup@v4 name: Install pnpm id: pnpm-install with: @@ -35,7 +35,7 @@ jobs: shell: bash run: | echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV - - uses: actions/cache@v3 + - uses: actions/cache@v4 name: setup pnpm cache with: path: ${{ env.STORE_PATH }} diff --git a/packages/core/test/fixtures/prepack-ci/output/.github/workflows/ci.yml b/packages/core/test/fixtures/prepack-ci/output/.github/workflows/ci.yml index b116a1b01..4701374b9 100644 --- a/packages/core/test/fixtures/prepack-ci/output/.github/workflows/ci.yml +++ b/packages/core/test/fixtures/prepack-ci/output/.github/workflows/ci.yml @@ -12,11 +12,11 @@ jobs: strategy: matrix: - node-version: [16.x, 18.x] + node-version: [20.x, 22.x] steps: - name: Checkout code repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 - name: Use Node.js ${{ matrix.node-version }} @@ -24,7 +24,7 @@ jobs: with: node-version: ${{ matrix.node-version }} # Install pnpm depends on package.json packageManager field - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v4 name: Install pnpm id: pnpm-install with: @@ -33,7 +33,7 @@ jobs: shell: bash run: | echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - uses: actions/cache@v3 + - uses: actions/cache@v4 name: Setup pnpm cache with: path: ${{ env.STORE_PATH }} diff --git a/packages/core/test/fixtures/prepack-ci/output/.github/workflows/release.yml b/packages/core/test/fixtures/prepack-ci/output/.github/workflows/release.yml index b0eb40f14..0a4c8f33a 100644 --- a/packages/core/test/fixtures/prepack-ci/output/.github/workflows/release.yml +++ b/packages/core/test/fixtures/prepack-ci/output/.github/workflows/release.yml @@ -17,15 +17,15 @@ jobs: pull-requests: write steps: - name: Checkout code repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 20 # Install pnpm depends on package.json packageManager field - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v4 name: Install pnpm id: pnpm-install with: @@ -34,7 +34,7 @@ jobs: shell: bash run: | echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - uses: actions/cache@v3 + - uses: actions/cache@v4 name: Setup pnpm cache with: path: ${{ env.STORE_PATH }} diff --git a/packages/core/test/fixtures/prepack-ci/output/.github/workflows/snapshot-release.yml b/packages/core/test/fixtures/prepack-ci/output/.github/workflows/snapshot-release.yml index b9ce6f924..46a87140e 100644 --- a/packages/core/test/fixtures/prepack-ci/output/.github/workflows/snapshot-release.yml +++ b/packages/core/test/fixtures/prepack-ci/output/.github/workflows/snapshot-release.yml @@ -18,14 +18,14 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout code repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 - name: setup node.js uses: actions/setup-node@v4 with: - node-version: 18 - - uses: pnpm/action-setup@v2 + node-version: 20 + - uses: pnpm/action-setup@v4 name: Install pnpm id: pnpm-install with: @@ -35,7 +35,7 @@ jobs: shell: bash run: | echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV - - uses: actions/cache@v3 + - uses: actions/cache@v4 name: setup pnpm cache with: path: ${{ env.STORE_PATH }} diff --git a/packages/core/test/fixtures/prepack/expected/.eslintrc b/packages/core/test/fixtures/prepack/expected/.eslintrc new file mode 100644 index 000000000..c57fa89fc --- /dev/null +++ b/packages/core/test/fixtures/prepack/expected/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": ["@aiou"] +} diff --git a/packages/core/test/fixtures/prepack/expected/.github/workflows/ci.yml b/packages/core/test/fixtures/prepack/expected/.github/workflows/ci.yml index b116a1b01..3118ab568 100644 --- a/packages/core/test/fixtures/prepack/expected/.github/workflows/ci.yml +++ b/packages/core/test/fixtures/prepack/expected/.github/workflows/ci.yml @@ -3,7 +3,7 @@ name: Node.js CI on: push: pull_request: - branches: [master, release] + branches: [master,release] jobs: test: @@ -12,40 +12,22 @@ jobs: strategy: matrix: - node-version: [16.x, 18.x] + node-version: [14.x, 16.x] steps: - - name: Checkout code repository - uses: actions/checkout@v4 + - name: checkout code repository + uses: actions/checkout@v2 with: fetch-depth: 0 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 + uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - # Install pnpm depends on package.json packageManager field - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - run_install: false - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Install + - name: Install pnpm + run: npm i pnpm@7.32.1 -g + - name: Install run: | pnpm install --frozen-lockfile=false - # - name: Build - # run: | - # pnpm build - name: Test run: | pnpm test \ No newline at end of file diff --git a/packages/core/test/fixtures/prepack/expected/.github/workflows/release.yml b/packages/core/test/fixtures/prepack/expected/.github/workflows/release.yml index b0eb40f14..78b6cec7f 100644 --- a/packages/core/test/fixtures/prepack/expected/.github/workflows/release.yml +++ b/packages/core/test/fixtures/prepack/expected/.github/workflows/release.yml @@ -5,10 +5,13 @@ on: - main - master - 'releases/*' + +concurrency: ${{ github.workflow }}-${{ github.ref }} + env: CI: true jobs: - release: + version: timeout-minutes: 15 runs-on: ubuntu-latest permissions: @@ -16,34 +19,18 @@ jobs: packages: write pull-requests: write steps: - - name: Checkout code repository - uses: actions/checkout@v4 + - name: checkout code repository + uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Setup Node.js - uses: actions/setup-node@v4 + - name: setup node.js + uses: actions/setup-node@v2 with: - node-version: 18 - # Install pnpm depends on package.json packageManager field - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - run_install: false - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Install - run: | - pnpm install --frozen-lockfile=false + node-version: 14 + - name: install pnpm + run: npm i pnpm@7.32.1 -g + - name: install dependencies + run: pnpm install --frozen-lockfile=false - name: create and publish versions uses: changesets/action@v1 with: diff --git a/packages/core/test/fixtures/prepack/expected/.github/workflows/snapshot-release.yml b/packages/core/test/fixtures/prepack/expected/.github/workflows/snapshot-release.yml index b9ce6f924..eb676bd87 100644 --- a/packages/core/test/fixtures/prepack/expected/.github/workflows/snapshot-release.yml +++ b/packages/core/test/fixtures/prepack/expected/.github/workflows/snapshot-release.yml @@ -1,70 +1,41 @@ -name: Snapshot Release +name: Release on: push: - paths: - - ".changeset/**" branches: - snapshot - pull_request: - paths: - - ".changeset/**" - branches: [master, main, release] + +concurrency: ${{ github.workflow }}-${{ github.ref }} + env: CI: true jobs: - snapshot-release: - # Only repo owner can publish snapshot version when create pr target master - if: ${{ github.triggering_actor == github.repository_owner }} + version: + timeout-minutes: 15 runs-on: ubuntu-latest + permissions: + contents: write + packages: write + pull-requests: write steps: - name: checkout code repository - uses: actions/checkout@v4 + uses: actions/checkout@v2 with: fetch-depth: 0 - name: setup node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v2 with: - node-version: 18 - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - run_install: false - - name: get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV - - uses: actions/cache@v3 - name: setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- + node-version: 14 + - name: install pnpm + run: npm i pnpm@7.32.1 -g - name: install dependencies run: pnpm install --frozen-lockfile=false - - name: Creating .npmrc - run: | - cat << EOF > "$HOME/.npmrc" - //registry.npmjs.org/:_authToken=$NPM_TOKEN - EOF - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - # enable it if develop swc plugin - # - name: install Rust - # uses: actions-rs/toolchain@v1 - # with: - # profile: minimal - # - name: install wasm target - # shell: bash - # run: | - # rustup target add wasm32-wasi - name: create and publish versions - run: | - pnpm ci:snapshot - pnpm changeset pre enter snapshot - pnpm ci:prerelease + uses: changesets/action@v1 + with: + version: pnpm ci:snapshot + commit: "chore: update versions" + title: "chore: update versions" + publish: pnpm ci:prerelease env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/packages/core/test/fixtures/prepack/expected/package.json b/packages/core/test/fixtures/prepack/expected/package.json index dc0aa1148..430b61a17 100644 --- a/packages/core/test/fixtures/prepack/expected/package.json +++ b/packages/core/test/fixtures/prepack/expected/package.json @@ -9,19 +9,19 @@ "test": "echo \"Error: no test specified\" && exit 1", "ci:publish": "pnpm run build && pnpm changeset publish", "ci:version": "pnpm changeset version", - "ci:snapshot": "pnpm changeset version --snapshot snapshot", - "ci:prerelease": "pnpm run build && pnpm changeset publish --no-git-tag --snapshot", + "ci:snapshot": "pnpm changeset version --snapshot beta", + "ci:prerelease": "pnpm run build && pnpm changeset publish --tag beta", "lint:fix": "eslint . --fix", "prepare": "husky install" }, "lint-staged": { - "**/**/*.{js,ts,tsx,json,yml,yaml,md}": ["eslint --fix"] + "**/**/*.{js,ts,tsx,vue,json,yml,yaml}": ["eslint --fix"] }, "devDependencies": { - "@aiou/eslint-config": "^1.2.1", + "@aiou/eslint-config": "^0.10.0", "@changesets/cli": "^2.26.0", "comparedir-test": "^1.0.1", - "eslint": "^8.56.0", + "eslint": "^8.32.0", "husky": "^8.0.3", "lint-staged": "^13.1.0", "typescript": "^4.6.4", diff --git a/packages/core/test/fixtures/prepack/output/.eslintrc b/packages/core/test/fixtures/prepack/output/.eslintrc new file mode 100644 index 000000000..c57fa89fc --- /dev/null +++ b/packages/core/test/fixtures/prepack/output/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": ["@aiou"] +} diff --git a/packages/core/test/fixtures/prepack/output/.github/workflows/ci.yml b/packages/core/test/fixtures/prepack/output/.github/workflows/ci.yml index b116a1b01..3118ab568 100644 --- a/packages/core/test/fixtures/prepack/output/.github/workflows/ci.yml +++ b/packages/core/test/fixtures/prepack/output/.github/workflows/ci.yml @@ -3,7 +3,7 @@ name: Node.js CI on: push: pull_request: - branches: [master, release] + branches: [master,release] jobs: test: @@ -12,40 +12,22 @@ jobs: strategy: matrix: - node-version: [16.x, 18.x] + node-version: [14.x, 16.x] steps: - - name: Checkout code repository - uses: actions/checkout@v4 + - name: checkout code repository + uses: actions/checkout@v2 with: fetch-depth: 0 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 + uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - # Install pnpm depends on package.json packageManager field - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - run_install: false - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Install + - name: Install pnpm + run: npm i pnpm@7.32.1 -g + - name: Install run: | pnpm install --frozen-lockfile=false - # - name: Build - # run: | - # pnpm build - name: Test run: | pnpm test \ No newline at end of file diff --git a/packages/core/test/fixtures/prepack/output/.github/workflows/release.yml b/packages/core/test/fixtures/prepack/output/.github/workflows/release.yml index b0eb40f14..78b6cec7f 100644 --- a/packages/core/test/fixtures/prepack/output/.github/workflows/release.yml +++ b/packages/core/test/fixtures/prepack/output/.github/workflows/release.yml @@ -5,10 +5,13 @@ on: - main - master - 'releases/*' + +concurrency: ${{ github.workflow }}-${{ github.ref }} + env: CI: true jobs: - release: + version: timeout-minutes: 15 runs-on: ubuntu-latest permissions: @@ -16,34 +19,18 @@ jobs: packages: write pull-requests: write steps: - - name: Checkout code repository - uses: actions/checkout@v4 + - name: checkout code repository + uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Setup Node.js - uses: actions/setup-node@v4 + - name: setup node.js + uses: actions/setup-node@v2 with: - node-version: 18 - # Install pnpm depends on package.json packageManager field - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - run_install: false - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Install - run: | - pnpm install --frozen-lockfile=false + node-version: 14 + - name: install pnpm + run: npm i pnpm@7.32.1 -g + - name: install dependencies + run: pnpm install --frozen-lockfile=false - name: create and publish versions uses: changesets/action@v1 with: diff --git a/packages/core/test/fixtures/prepack/output/.github/workflows/snapshot-release.yml b/packages/core/test/fixtures/prepack/output/.github/workflows/snapshot-release.yml index b9ce6f924..eb676bd87 100644 --- a/packages/core/test/fixtures/prepack/output/.github/workflows/snapshot-release.yml +++ b/packages/core/test/fixtures/prepack/output/.github/workflows/snapshot-release.yml @@ -1,70 +1,41 @@ -name: Snapshot Release +name: Release on: push: - paths: - - ".changeset/**" branches: - snapshot - pull_request: - paths: - - ".changeset/**" - branches: [master, main, release] + +concurrency: ${{ github.workflow }}-${{ github.ref }} + env: CI: true jobs: - snapshot-release: - # Only repo owner can publish snapshot version when create pr target master - if: ${{ github.triggering_actor == github.repository_owner }} + version: + timeout-minutes: 15 runs-on: ubuntu-latest + permissions: + contents: write + packages: write + pull-requests: write steps: - name: checkout code repository - uses: actions/checkout@v4 + uses: actions/checkout@v2 with: fetch-depth: 0 - name: setup node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v2 with: - node-version: 18 - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - run_install: false - - name: get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV - - uses: actions/cache@v3 - name: setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- + node-version: 14 + - name: install pnpm + run: npm i pnpm@7.32.1 -g - name: install dependencies run: pnpm install --frozen-lockfile=false - - name: Creating .npmrc - run: | - cat << EOF > "$HOME/.npmrc" - //registry.npmjs.org/:_authToken=$NPM_TOKEN - EOF - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - # enable it if develop swc plugin - # - name: install Rust - # uses: actions-rs/toolchain@v1 - # with: - # profile: minimal - # - name: install wasm target - # shell: bash - # run: | - # rustup target add wasm32-wasi - name: create and publish versions - run: | - pnpm ci:snapshot - pnpm changeset pre enter snapshot - pnpm ci:prerelease + uses: changesets/action@v1 + with: + version: pnpm ci:snapshot + commit: "chore: update versions" + title: "chore: update versions" + publish: pnpm ci:prerelease env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/packages/core/test/fixtures/prepack/output/package.json b/packages/core/test/fixtures/prepack/output/package.json index dc0aa1148..430b61a17 100644 --- a/packages/core/test/fixtures/prepack/output/package.json +++ b/packages/core/test/fixtures/prepack/output/package.json @@ -9,19 +9,19 @@ "test": "echo \"Error: no test specified\" && exit 1", "ci:publish": "pnpm run build && pnpm changeset publish", "ci:version": "pnpm changeset version", - "ci:snapshot": "pnpm changeset version --snapshot snapshot", - "ci:prerelease": "pnpm run build && pnpm changeset publish --no-git-tag --snapshot", + "ci:snapshot": "pnpm changeset version --snapshot beta", + "ci:prerelease": "pnpm run build && pnpm changeset publish --tag beta", "lint:fix": "eslint . --fix", "prepare": "husky install" }, "lint-staged": { - "**/**/*.{js,ts,tsx,json,yml,yaml,md}": ["eslint --fix"] + "**/**/*.{js,ts,tsx,vue,json,yml,yaml}": ["eslint --fix"] }, "devDependencies": { - "@aiou/eslint-config": "^1.2.1", + "@aiou/eslint-config": "^0.10.0", "@changesets/cli": "^2.26.0", "comparedir-test": "^1.0.1", - "eslint": "^8.56.0", + "eslint": "^8.32.0", "husky": "^8.0.3", "lint-staged": "^13.1.0", "typescript": "^4.6.4", diff --git a/packages/core/test/utils.test.ts b/packages/core/test/utils.test.ts index ac2f6b11f..4869a9b71 100644 --- a/packages/core/test/utils.test.ts +++ b/packages/core/test/utils.test.ts @@ -26,9 +26,19 @@ it('make uniq id', () => { }) describe('parse wanted pkg', () => { - it('default', () => { + it('url', () => { console.log(parseWantedPackage('https://github.com/pnpm/pnpm')) }) + + it('latest', () => { + console.log(parseWantedPackage('@aiou/generator-pnpm-ci@latest')) + expect(parseWantedPackage('@aiou/generator-pnpm-ci@latest')).toMatchObject({ + alias: '@aiou/generator-pnpm-ci', + name: '@aiou/generator-pnpm-ci', + pref: '@aiou/generator-pnpm-ci@latest', + version: 'latest', + }) + }) }) describe('find perf package by uniq pk name', () => { @@ -110,7 +120,7 @@ describe('find perf package by uniq pk name', () => { const item = findPrefPackageByPk(packages, { input: '@aiou/react-template@2.x' }) expect(item).toMatchObject({ name: '@aiou/react-template', - pref: '@aiou/react-template', + pref: '@aiou/react-template@2.x', version: '2.x', alias: '@aiou/react-template', }) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7057766b7..ce14a89ef 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -54,7 +54,7 @@ importers: version: 0.5.21 devDependencies: '@aiou/mario': - specifier: workspace:^0.3.0 + specifier: workspace:^0.3.1 version: link:../mario '@aiou/schema': specifier: workspace:^1.1.0 @@ -207,8 +207,8 @@ importers: specifier: ^0.7.7 version: 0.7.13(c8@7.14.0) vitest-extra: - specifier: ^0.0.4 - version: 0.0.4(vitest@0.7.13(c8@7.14.0)) + specifier: ^0.1.0 + version: 0.1.0(vitest@0.7.13(c8@7.14.0)) write-yaml-file: specifier: ^5.0.0 version: 5.0.0 @@ -5496,8 +5496,8 @@ packages: bundledDependencies: - lodash-es - vitest-extra@0.0.4: - resolution: {integrity: sha512-7T8ES01B8qLkvSySmuDf5Rgxfnb/1rH7dZsAN1GWvnzSetv6L4M0yWEu4ejL1rmnhfJuOVczU2JK+uDJLcbgPQ==} + vitest-extra@0.1.0: + resolution: {integrity: sha512-CGt3CvrHWDCd2QxlLiooiSL6630NoWC0tMuBNpmarF2qmlVckTQH4OlKNewZyNfMbKOx1ZtpfU0C8jhIQoqaNw==} peerDependencies: vitest: '>=0.7.7' @@ -11580,7 +11580,7 @@ snapshots: globby: 13.1.1 vitest: 0.7.13(c8@7.14.0) - vitest-extra@0.0.4(vitest@0.7.13(c8@7.14.0)): + vitest-extra@0.1.0(vitest@0.7.13(c8@7.14.0)): dependencies: debug: 4.4.1(supports-color@9.4.0) fs-extra: 10.0.1