create-packkit 2.2.0 → 2.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-packkit",
3
- "version": "2.2.0",
3
+ "version": "2.3.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/args.js CHANGED
@@ -54,6 +54,7 @@ export function parseCliArgs(argv) {
54
54
  canary: { type: 'boolean' },
55
55
  'pkg-checks': { type: 'boolean' },
56
56
  knip: { type: 'boolean' },
57
+ 'size-limit': { type: 'boolean' },
57
58
  jsr: { type: 'boolean' },
58
59
  help: { type: 'boolean', short: 'h' },
59
60
  version: { type: 'boolean', short: 'v' },
@@ -83,6 +84,7 @@ export function parseCliArgs(argv) {
83
84
  if (values.canary) overrides.canary = true;
84
85
  if (values['pkg-checks']) overrides.pkgChecks = true;
85
86
  if (values.knip) overrides.knip = true;
87
+ if (values['size-limit']) overrides.sizeLimit = true;
86
88
  if (values.jsr) overrides.jsr = true;
87
89
  for (const [flag, key] of Object.entries(NEGATABLE)) {
88
90
  if (values[flag]) overrides[key] = false;
package/src/cli/index.js CHANGED
@@ -47,6 +47,7 @@ Options:
47
47
  --workflows <ci|npm-publish|pages|codeql|codecov|stale> (repeatable)
48
48
  --deps <renovate|dependabot|none> --license <MIT|Apache-2.0|ISC|none>
49
49
  --pkg-checks (publint + are-the-types-wrong) --knip --jsr --canary
50
+ --size-limit (bundle-size budget, libraries)
50
51
  --no-coverage --no-community --no-agents --no-vscode --no-editorconfig
51
52
  --schema Print the full option/preset schema as JSON (for tools/agents)
52
53
  -h, --help Show this help
@@ -15,6 +15,7 @@ import githooks from './githooks.js';
15
15
  import release from './release.js';
16
16
  import cli from './cli.js';
17
17
  import checks from './checks.js';
18
+ import sizelimit from './sizelimit.js';
18
19
  import jsr from './jsr.js';
19
20
  import workflows from './workflows.js';
20
21
  import storybook from './storybook.js';
@@ -38,6 +39,7 @@ export default [
38
39
  release,
39
40
  cli,
40
41
  checks,
42
+ sizelimit,
41
43
  jsr,
42
44
  workflows,
43
45
  storybook,
@@ -0,0 +1,23 @@
1
+ // size-limit: a bundle-size budget for published libraries. Measures the
2
+ // brotli-compressed size of the built entry and fails when it exceeds the
3
+ // limit — cheap insurance against a dependency silently bloating the package.
4
+ import { toJson } from '../render.js';
5
+
6
+ export default {
7
+ id: 'sizelimit',
8
+ active: (cfg) => cfg.sizeLimit,
9
+ apply(cfg) {
10
+ return {
11
+ files: {
12
+ '.size-limit.json': toJson([{ name: cfg.name, path: 'dist/index.js', limit: '10 kB' }]),
13
+ },
14
+ pkg: {
15
+ scripts: { size: 'size-limit' },
16
+ devDependencies: {
17
+ 'size-limit': '^11.0.0',
18
+ '@size-limit/preset-small-lib': '^11.0.0',
19
+ },
20
+ },
21
+ };
22
+ },
23
+ };
@@ -80,6 +80,7 @@ function ciWorkflow(cfg, codecov) {
80
80
  if (cfg.test !== 'none') jobs.push(` - run: ${pmRun(cfg, codecov ? 'coverage' : 'test')}`);
81
81
  if (cfg.knip) jobs.push(` - run: ${pmRun(cfg, 'knip')}`);
82
82
  if (cfg.hasBuild) jobs.push(` - run: ${pmRun(cfg, 'build')}`);
83
+ if (cfg.sizeLimit) jobs.push(` - run: ${pmRun(cfg, 'size')}`); // after build (measures dist)
83
84
  if (cfg.pkgChecks) jobs.push(` - run: ${pmRun(cfg, 'check:pkg')}`); // after build (attw packs dist)
84
85
  const cov = codecov
85
86
  ? '\n - uses: codecov/codecov-action@v4\n with:\n token: ${{ secrets.CODECOV_TOKEN }}'
@@ -102,6 +102,7 @@ export const OPTIONS = {
102
102
  canary: { group: 'release', type: 'boolean', label: 'Snapshot / canary release workflow (Changesets)', default: false },
103
103
  pkgChecks: { group: 'quality', type: 'boolean', label: 'Package checks (publint + are-the-types-wrong)', default: false },
104
104
  knip: { group: 'quality', type: 'boolean', label: 'Knip (unused files / deps / exports)', default: false },
105
+ sizeLimit: { group: 'quality', type: 'boolean', label: 'size-limit (bundle-size budget, libraries)', default: false },
105
106
 
106
107
  // ---- lint / format ----
107
108
  lint: {
@@ -260,6 +261,8 @@ export function normalizeConfig(input = {}) {
260
261
  if (!cfg.publishable) cfg.pkgChecks = false;
261
262
  // Sourcemaps + shipped source only matter for a published package.
262
263
  if (!cfg.publishable) cfg.sourcemaps = false;
264
+ // A bundle-size budget needs a published package with a built entry.
265
+ if (!(cfg.publishable && cfg.hasBuild)) cfg.sizeLimit = false;
263
266
  // Env validation is for server-side runtimes (services / CLIs), not libs/apps.
264
267
  if (!(cfg.hasService || cfg.hasCli)) cfg.env = false;
265
268
  // Canary snapshots ride on the Changesets flow.