diff --git a/.gitignore b/.gitignore index aecc0f6..36d7ca4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ template/pnpm-lock.yaml +test/ diff --git a/.npmignore b/.npmignore index f824fca..2a12a1f 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,6 @@ -/eslint.config.js -/.github/ +.gitattributes +.github/ +eslint.config.js +test/* +template/pnpm-lock.yaml +template/node-modules diff --git a/eslint.config.js b/eslint.config.js index dd62961..22d7a96 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -4,4 +4,13 @@ import ts from '@cto.af/eslint-config/ts.js'; export default [ ...es6, ...ts, + { + files: [ + 'template/**', + 'test/**', + ], + rules: { + 'n/no-missing-import': 'off', + }, + }, ]; diff --git a/index.js b/index.js index 56cff8b..15e9353 100755 --- a/index.js +++ b/index.js @@ -8,6 +8,7 @@ import {Scaffold as scaffold} from 'simple-scaffold'; const cwd = process.cwd(); const base = path.basename(cwd); const parent = path.basename(path.dirname(cwd)); +const args = process.argv.slice(2); const org = parent.startsWith('@') ? parent : ''; const name = org ? `${parent}/${base}` : base; @@ -31,17 +32,21 @@ await scaffold({ email, login, user: user.login, - npmignore: '.npmignore', gitignore: '.gitignore', gitattributes: '.gitattributes', }, }); -const v = {verbose: 'full'}; -await $(v)`ncu -u`; -await $(v)`pnpm install`; -await $(v)`git init .`; -await $(v)`git add .`; -await $(v)`git ci -m ${'Initial checkin'}`; -await $(v)`npm run build`; -await $(v)`gh secret set NPM_TOKEN`; +if (!args.includes('--noexec')) { + const v = {verbose: 'full'}; + await $(v)`ncu -u`; + await $(v)`pnpm install`; + await $(v)`npm run build`; + if (!args.includes('--nogit')) { + await $(v)`git init .`; + await $(v)`git add .`; + await $(v)`git ci -m ${'Initial checkin'}`; + await $(v)`gh secret set NPM_TOKEN`; + await $(v)`gh secret set CODECOV_TOKEN`; + } +} diff --git a/package.json b/package.json index e6eb2d3..694e04e 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,9 @@ "url": "https://github.com/cto-af/create/issues" }, "scripts": { - "lint": "eslint ." + "lint": "eslint .", + "test": "rm -rf test && mkdir test && cd test && ../index.js --noexec", + "build": "npm run lint && npm run test" }, "dependencies": { "execa": "9.5.2", diff --git a/template/.gitattributes b/template/.gitattributes deleted file mode 100644 index 9b2b538..0000000 --- a/template/.gitattributes +++ /dev/null @@ -1,21 +0,0 @@ -*.cjs text eol=lf -*.css text eol=lf -*.csv text eol=lf -*.html text eol=lf -*.ico binary -*.jpg binary -*.js text eol=lf -*.json text eol=lf -*.map text eol=lf -*.mjs text eol=lf -*.mk text eol=lf -*.pdf binary -*.peg.js text eol=lf linguist-language=PEG.js -*.peggy text eol=lf linguist-language=PEG.js -*.pegjs text eol=lf linguist-language=PEG.js -*.png binary -*.rs text eol=lf -*.ts text eol=lf -*.tsv text eol=lf -*.tsx text eol=lf -Makefile text eol=lf diff --git a/template/.github/workflows/node.js.yml b/template/.github/workflows/node.js.yml index 0b88165..c66416f 100644 --- a/template/.github/workflows/node.js.yml +++ b/template/.github/workflows/node.js.yml @@ -1,4 +1,3 @@ ---- name: Tests on: @@ -18,12 +17,6 @@ jobs: runs-on: $\{{ matrix.platform }} steps: - - name: Check secrets - env: - CODECOV_TOKEN: $\{{ secrets.CODECOV_TOKEN }} - if: ${{ env.CODECOV_TOKEN == '' }} - run: | - echo the secret "CODECOV_TOKEN" is not available - uses: actions/checkout@v4 with: submodules: true @@ -38,7 +31,3 @@ jobs: run: pnpm install -r - name: Test $\{{ matrix.node-version }} $\{{ matrix.platform }} run: npm run build - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v5 - with: - token: $\{{ secrets.CODECOV_TOKEN }} diff --git a/template/.github/workflows/publish.yml b/template/.github/workflows/publish.yml index d4e163c..0bd1517 100644 --- a/template/.github/workflows/publish.yml +++ b/template/.github/workflows/publish.yml @@ -10,12 +10,6 @@ jobs: contents: write id-token: write steps: - - name: Check secrets - env: - NPM_TOKEN: $\{{ secrets.NPM_TOKEN }} - if: ${{ env.NPM_TOKEN == '' }} - run: | - echo the secret "NPM_TOKEN" is not available - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 - uses: actions/setup-node@v4 diff --git a/template/package.json b/template/package.json index 703e8d1..901d8b0 100644 --- a/template/package.json +++ b/template/package.json @@ -21,7 +21,7 @@ "scripts": { "clean": "rm -rf coverage docs lib", "lint": "eslint .", - "pretest": "tsup --inlineSourceMap", + "pretest": "tsup --sourcemap inline", "test": "c8 node --test", "posttest": "tsup --silent", "docs": "typedoc", @@ -31,6 +31,7 @@ "devDependencies": { "@cto.af/eslint-config": "5.1.11", "c8": "10.1.3", + "eslint": "9.21.0", "eslint-plugin-jsdoc": "50.6.3", "eslint-plugin-markdown": "5.1.0", "tsup": "8.3.6", diff --git a/template/test/index.test.js b/template/test/index.test.js index 0f7f416..55d60fc 100644 --- a/template/test/index.test.js +++ b/template/test/index.test.js @@ -1,6 +1,7 @@ import assert from 'node:assert'; +import {foo} from '../lib/index.js'; import test from 'node:test'; test('index', () => { - assert(true); + assert.equal(foo(), 2); });