create-packkit 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/cli/index.js +29 -0
- package/src/core/features/workflows.js +6 -6
- package/src/core/presets.js +4 -0
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ No install needed: **[danmat.github.io/create-packkit](https://danmat.github.io/
|
|
|
49
49
|
|
|
50
50
|
## Presets
|
|
51
51
|
|
|
52
|
-
`ts-lib` · `js-lib` · `ts-cli` / `cli` · `react-lib` · `react-lib-js` · `react-app` · `vue-lib` · `svelte-lib` · `node-service` · `oss` · `minimal` · `full` — named bundles of the options above. See the [roadmap](ROADMAP.md) for what's next.
|
|
52
|
+
`ts-lib` · `js-lib` · `ts-cli` / `cli` · `react-lib` · `react-lib-js` · `react-app` · `vue-lib` · `vue-app` · `svelte-lib` · `svelte-app` · `node-service` · `oss` · `minimal` · `full` — named bundles of the options above. See the [roadmap](ROADMAP.md) for what's next.
|
|
53
53
|
|
|
54
54
|
## How it works
|
|
55
55
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-packkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Highly configurable scaffolder for modern npm packages and CLIs — pick your stack (TS/JS, bundler, tests, linter, CI, releases) from a CLI or a web configurator.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/cli/index.js
CHANGED
|
@@ -110,8 +110,37 @@ export async function run(argv = process.argv.slice(2)) {
|
|
|
110
110
|
console.log(done);
|
|
111
111
|
if (next.length) console.log('\nNext steps:\n ' + next.join('\n '));
|
|
112
112
|
}
|
|
113
|
+
|
|
114
|
+
const latest = await checkForUpdate(pkgVersion());
|
|
115
|
+
if (latest) console.log(`\n↑ A newer create-packkit is available: ${latest} (you have ${pkgVersion()}). Use @latest to update.`);
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
function runWord(config) {
|
|
116
119
|
return config.packageManager === 'npm' ? 'npm run' : config.packageManager;
|
|
117
120
|
}
|
|
121
|
+
|
|
122
|
+
// Best-effort update check — TTY only, short timeout, never throws or blocks.
|
|
123
|
+
async function checkForUpdate(current) {
|
|
124
|
+
try {
|
|
125
|
+
if (process.env.CI || process.env.NO_UPDATE_NOTIFIER || !process.stdout.isTTY) return null;
|
|
126
|
+
const ctrl = new AbortController();
|
|
127
|
+
const timer = setTimeout(() => ctrl.abort(), 1500);
|
|
128
|
+
const res = await fetch('https://registry.npmjs.org/create-packkit/latest', { signal: ctrl.signal });
|
|
129
|
+
clearTimeout(timer);
|
|
130
|
+
if (!res.ok) return null;
|
|
131
|
+
const { version } = await res.json();
|
|
132
|
+
return version && isNewer(version, current) ? version : null;
|
|
133
|
+
} catch {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function isNewer(latest, current) {
|
|
139
|
+
const a = latest.split('.').map(Number);
|
|
140
|
+
const b = current.split('.').map(Number);
|
|
141
|
+
for (let i = 0; i < 3; i++) {
|
|
142
|
+
if ((a[i] || 0) > (b[i] || 0)) return true;
|
|
143
|
+
if ((a[i] || 0) < (b[i] || 0)) return false;
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
@@ -140,8 +140,12 @@ function releaseWorkflow(cfg) {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
function pagesWorkflow(cfg) {
|
|
143
|
+
// Storybook projects deploy the built catalog; everything else serves ./docs.
|
|
144
|
+
const build = cfg.storybook
|
|
145
|
+
? [setupSteps(cfg), ` - run: ${pmRun(cfg, 'build-storybook')}`, ' - uses: actions/configure-pages@v5', ' - uses: actions/upload-pages-artifact@v3', ' with:', ' path: ./storybook-static']
|
|
146
|
+
: [' - uses: actions/checkout@v4', ' - uses: actions/configure-pages@v5', ' - uses: actions/upload-pages-artifact@v3', ' with:', ' path: ./docs'];
|
|
143
147
|
return [
|
|
144
|
-
|
|
148
|
+
`name: Deploy ${cfg.storybook ? 'Storybook' : 'Pages'}`,
|
|
145
149
|
'on:',
|
|
146
150
|
' push:',
|
|
147
151
|
' branches: [main]',
|
|
@@ -159,11 +163,7 @@ function pagesWorkflow(cfg) {
|
|
|
159
163
|
' url: ${{ steps.deployment.outputs.page_url }}',
|
|
160
164
|
' runs-on: ubuntu-latest',
|
|
161
165
|
' steps:',
|
|
162
|
-
'
|
|
163
|
-
' - uses: actions/configure-pages@v5',
|
|
164
|
-
' - uses: actions/upload-pages-artifact@v3',
|
|
165
|
-
' with:',
|
|
166
|
-
' path: ./docs',
|
|
166
|
+
build.join('\n'),
|
|
167
167
|
' - id: deployment',
|
|
168
168
|
' uses: actions/deploy-pages@v4',
|
|
169
169
|
'',
|
package/src/core/presets.js
CHANGED
|
@@ -10,7 +10,9 @@ export const PRESETS = {
|
|
|
10
10
|
'react-lib-js': { language: 'js', framework: 'react', target: ['library'], moduleFormat: 'dual', bundler: 'tsup', test: 'vitest' },
|
|
11
11
|
'react-app': { language: 'ts', framework: 'react', target: ['app'], test: 'vitest', release: 'none', workflows: ['ci'] },
|
|
12
12
|
'vue-lib': { language: 'ts', framework: 'vue', target: ['library'], test: 'vitest' },
|
|
13
|
+
'vue-app': { language: 'ts', framework: 'vue', target: ['app'], test: 'vitest', release: 'none', workflows: ['ci'] },
|
|
13
14
|
'svelte-lib': { language: 'ts', framework: 'svelte', target: ['library'], test: 'vitest' },
|
|
15
|
+
'svelte-app': { language: 'ts', framework: 'svelte', target: ['app'], test: 'vitest', release: 'none', workflows: ['ci'] },
|
|
14
16
|
'node-service': {
|
|
15
17
|
language: 'ts', target: ['service'], moduleFormat: 'esm', bundler: 'tsup',
|
|
16
18
|
test: 'vitest', lint: 'eslint-prettier', gitHooks: 'simple-git-hooks',
|
|
@@ -48,7 +50,9 @@ export const PRESET_INFO = {
|
|
|
48
50
|
'react-lib-js': 'React component library (JS) — JSX, peer deps, jsdom tests.',
|
|
49
51
|
'react-app': 'React SPA — Vite dev server, build, Testing Library.',
|
|
50
52
|
'vue-lib': 'Vue component library — Vite lib build (SFCs), dual + types.',
|
|
53
|
+
'vue-app': 'Vue SPA — Vite dev server, build, Testing Library.',
|
|
51
54
|
'svelte-lib': 'Svelte component library — ships source, peer svelte, jsdom tests.',
|
|
55
|
+
'svelte-app': 'Svelte SPA — Vite dev server, build, Testing Library.',
|
|
52
56
|
'node-service': 'Node HTTP service (Hono) — tsx dev, tsup build, Dockerfile.',
|
|
53
57
|
oss: 'Full open-source library — coverage, CodeQL, Codecov, Renovate, Changesets.',
|
|
54
58
|
minimal: 'Bare TS library — tsup only, no tests/lint/CI.',
|