diff --git a/.github/old/release.yml b/.github/old/release2.yml similarity index 62% rename from .github/old/release.yml rename to .github/old/release2.yml index 8733da1..a78b92e 100644 --- a/.github/old/release.yml +++ b/.github/old/release2.yml @@ -2,14 +2,16 @@ name: Release on: push: - tags: - - 'v*' + branches: + - main + - beta jobs: release: runs-on: ubuntu-latest permissions: - contents: write + contents: write # to be able to publish a GitHub release + id-token: write # to enable use of OIDC for npm provenance steps: - uses: actions/checkout@v3 with: @@ -25,6 +27,8 @@ jobs: - name: install run: pnpm i - - run: npx changelogithub + - name: release + run: pnpm semantic-release env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + NPM_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} diff --git a/.github/old/publish.yml b/.github/workflows/publish.yml similarity index 100% rename from .github/old/publish.yml rename to .github/workflows/publish.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a78b92e..8733da1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,16 +2,14 @@ name: Release on: push: - branches: - - main - - beta + tags: + - 'v*' jobs: release: runs-on: ubuntu-latest permissions: - contents: write # to be able to publish a GitHub release - id-token: write # to enable use of OIDC for npm provenance + contents: write steps: - uses: actions/checkout@v3 with: @@ -27,8 +25,6 @@ jobs: - name: install run: pnpm i - - name: release - run: pnpm semantic-release + - run: npx changelogithub env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - NPM_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} diff --git a/package.json b/package.json index 6d142fc..78b9b6e 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "@vitest/coverage-v8": "^0.34.3", "bumpp": "^9.2.0", "concurrently": "^8.2.1", + "conventional-changelog-conventionalcommits": "^7.0.1", "cross-env": "^7.0.3", "eslint": "^8.48.0", "eslint-plugin-simple-import-sort": "^10.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4088784..47f33d9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -46,6 +46,9 @@ devDependencies: concurrently: specifier: ^8.2.1 version: 8.2.1 + conventional-changelog-conventionalcommits: + specifier: ^7.0.1 + version: 7.0.1 cross-env: specifier: ^7.0.3 version: 7.0.3 @@ -1554,6 +1557,13 @@ packages: compare-func: 2.0.0 dev: true + /conventional-changelog-conventionalcommits@7.0.1: + resolution: {integrity: sha512-VfFJxBmi+LYXeb4pIfZGbuaFCpWZh0qXbUAKP/s6B8tigV6R4D8j5PDlTtMMWawa7+DcNySVoF7kPWz0EMYuCQ==} + engines: {node: '>=16'} + dependencies: + compare-func: 2.0.0 + dev: true + /conventional-changelog-writer@6.0.1: resolution: {integrity: sha512-359t9aHorPw+U+nHzUXHS5ZnPBOizRxfQsWT5ZDHBfvfxQOAik+yfuhKXG66CN5LEWPpMNnIMHUTCKeYNprvHQ==} engines: {node: '>=14'} diff --git a/release.config.cjs b/release.config.cjs index 41c72f9..1cdd9cf 100644 --- a/release.config.cjs +++ b/release.config.cjs @@ -3,4 +3,20 @@ /** @type {import('semantic-release').Options} */ module.exports = { branches: ['main', 'next', { name: 'beta', prerelease: true }], + plugins: [ + [ + '@semantic-release/commit-analyzer', + { + preset: 'conventionalcommits', + }, + ], + [ + '@semantic-release/release-notes-generator', + { + preset: 'conventionalcommits', + }, + ], + '@semantic-release/npm', + '@semantic-release/github', + ], }; diff --git a/src/commands/clean.ts b/src/commands/clean.ts deleted file mode 100644 index 2ae8ee6..0000000 --- a/src/commands/clean.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { cancel, confirm, isCancel, log, outro } from '@clack/prompts'; -import { command } from 'cleye'; -import colors from 'picocolors'; - -import { cleanWorkspaces } from '../operations/clean-workspaces.js'; - -export default command( - { - name: 'clean', - - help: { - description: 'Clean all workspaces codew stored', - }, - }, - async () => { - try { - const confirmed = await confirm({ - message: `Are you sure to clean all workspaces?`, - initialValue: false, - }); - if (!confirmed || isCancel(confirmed)) { - cancel(`Cancelled`); - process.exit(0); - } - - await cleanWorkspaces(); - - outro(colors.cyan('✔ Successfully cleaned.')); - process.exit(0); - } catch (e) { - log.error(`${e}`); - } - }, -); diff --git a/src/commands/list.ts b/src/commands/list.ts deleted file mode 100644 index 40938d7..0000000 --- a/src/commands/list.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { command } from 'cleye'; -import colors from 'picocolors'; - -import { getWorkspaces } from '../operations/get-workspaces.js'; - -export default command( - { - name: 'list', - - help: { - description: 'List workspaces', - }, - }, - async () => { - const workspaces = await getWorkspaces(); - const msg = [ - `${colors.cyan('All workspaces')} (total: ${workspaces.length})`, - ...workspaces.map( - (w) => `${colors.white(w.codeWorkspacePath)} ${colors.dim(w.dirPath)}`, - ), - ].join('\n'); - console.log(msg); - }, -); diff --git a/src/index.ts b/src/index.ts index 9c83cbe..cbdc779 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,8 +4,6 @@ import { log } from '@clack/prompts'; import { cli } from 'cleye'; import { description, version } from '../package.json'; -import clean from './commands/clean.js'; -import list from './commands/list.js'; import { checkDir } from './operations/check-dir.js'; import { createWorkspace } from './operations/create-workspace.js'; import { getWorkspace } from './operations/get-workspace.js'; @@ -27,7 +25,7 @@ cli( examples: ['codew .'], }, - commands: [list, clean], + commands: [], }, async (argv) => { const path = argv._.path; diff --git a/test/operations/create-workspace.test.ts b/test/operations/create-workspace.test.ts index 57a51a8..48ef126 100644 --- a/test/operations/create-workspace.test.ts +++ b/test/operations/create-workspace.test.ts @@ -4,7 +4,7 @@ import { basename, resolve } from 'node:path'; import { afterEach, beforeEach, expect, test, vi } from 'vitest'; -import { DbData } from '../../src/db.ts'; +import { DbData } from '../../src/db.js'; import { createWorkspace } from '../../src/operations/create-workspace.js'; const mocks = vi.hoisted(() => { diff --git a/tsconfig.json b/tsconfig.json index 7994505..2e8e447 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,8 +7,6 @@ "strict": true, "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "allowImportingTsExtensions": true, "resolveJsonModule": true, "isolatedModules": true },