@stack-dev/cli 0.1.7 → 0.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/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +17 -0
- package/dist/index.js +1105 -743
- package/dist/index.mjs +1103 -741
- package/package.json +6 -5
- package/src/index.ts +11 -10
- package/src/packages/cli-app/create-cli-app.ts +74 -0
- package/src/packages/cli-app/files/eslint-config-file-generator.ts +11 -0
- package/src/packages/cli-app/files/index-file-generator.ts +24 -0
- package/src/packages/cli-app/files/prettier-config-file-generator.ts +11 -0
- package/src/packages/cli-app/files/tsconfig-file-generator.ts +15 -0
- package/src/packages/cli-app/files/tsup-file-generator.ts +20 -0
- package/src/packages/cli-app/files/vitest-config-file-generator.ts +19 -0
- package/src/packages/cli-app/index.ts +1 -0
- package/src/packages/fastify-app/create-fastify-app.ts +79 -0
- package/src/packages/fastify-app/files/eslint-config-file-generator.ts +11 -0
- package/src/packages/fastify-app/files/index-file-generator.ts +144 -0
- package/src/packages/fastify-app/files/prettier-config-file-generator.ts +11 -0
- package/src/packages/fastify-app/files/tsconfig-file-generator.ts +15 -0
- package/src/packages/fastify-app/files/tsup-file-generator.ts +20 -0
- package/src/packages/fastify-app/files/vitest-config-file-generator.ts +19 -0
- package/src/packages/fastify-app/index.ts +1 -0
- package/src/packages/index.ts +3 -0
- package/src/packages/react-package/create-react-package.ts +1 -9
- package/src/packages/react-package/styled-components-react-package/create-styled-components-react-package.ts +1 -3
- package/src/packages/react-package/{css-react-package/create-css-react-package.ts → unstyled-react-package/create-unstyled-react-package.ts} +8 -7
- package/src/packages/react-package/{css-react-package → unstyled-react-package}/files/button-file-generator.ts +2 -3
- package/src/packages/react-package/{css-react-package → unstyled-react-package}/files/button-spec-file-generator.ts +0 -10
- package/src/packages/react-package/{css-react-package → unstyled-react-package}/files/tsup-config-file-generator.ts +3 -6
- package/src/packages/vite-react-app/index.ts +1 -0
- package/src/utils/style-type.ts +1 -6
- package/src/packages/react-package/create-unstyled-react-package.ts +0 -3
- package/src/packages/react-package/css-react-package/files/button-css-module-file-generator.ts +0 -16
- /package/src/packages/react-package/{css-react-package → unstyled-react-package}/files/eslint-config-file-generator.ts +0 -0
- /package/src/packages/react-package/{css-react-package → unstyled-react-package}/files/index-file-generator.ts +0 -0
- /package/src/packages/react-package/{css-react-package → unstyled-react-package}/files/prettier-config-file-generator.ts +0 -0
- /package/src/packages/react-package/{css-react-package → unstyled-react-package}/files/tsconfig-file-generator.ts +0 -0
- /package/src/packages/react-package/{css-react-package → unstyled-react-package}/files/vitest-config-file-generator.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -23,9 +23,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
mod
|
|
24
24
|
));
|
|
25
25
|
|
|
26
|
-
// src/
|
|
27
|
-
var
|
|
28
|
-
var
|
|
26
|
+
// src/index.ts
|
|
27
|
+
var import_commander = require("commander");
|
|
28
|
+
var import_enquirer3 = require("enquirer");
|
|
29
|
+
|
|
30
|
+
// package.json
|
|
31
|
+
var version = "0.3.0";
|
|
29
32
|
|
|
30
33
|
// src/package-json/package-json.ts
|
|
31
34
|
var import_core = require("@stack-dev/core");
|
|
@@ -265,6 +268,8 @@ function getKeyIndex(s) {
|
|
|
265
268
|
}
|
|
266
269
|
|
|
267
270
|
// src/utils/utils.ts
|
|
271
|
+
var import_promises = __toESM(require("fs/promises"));
|
|
272
|
+
var import_node_path = __toESM(require("path"));
|
|
268
273
|
async function getDirectoryPackageJson(directory) {
|
|
269
274
|
const packageJsonPath = getPackageJSONPath(directory);
|
|
270
275
|
const packageJsonText = await import_promises.default.readFile(packageJsonPath, {
|
|
@@ -284,6 +289,185 @@ async function fileExists(filepath) {
|
|
|
284
289
|
}
|
|
285
290
|
}
|
|
286
291
|
|
|
292
|
+
// src/link-packages.ts
|
|
293
|
+
var import_promises3 = __toESM(require("fs/promises"));
|
|
294
|
+
var import_node_path2 = __toESM(require("path"));
|
|
295
|
+
|
|
296
|
+
// src/tsconfig/tsconfig.ts
|
|
297
|
+
var JSON52 = __toESM(require("json5"));
|
|
298
|
+
var import_core3 = require("@stack-dev/core");
|
|
299
|
+
var import_lodash3 = require("lodash");
|
|
300
|
+
|
|
301
|
+
// src/tsconfig/compiler-options.ts
|
|
302
|
+
var import_core2 = require("@stack-dev/core");
|
|
303
|
+
var import_lodash2 = require("lodash");
|
|
304
|
+
var CompilerOptions = class _CompilerOptions {
|
|
305
|
+
_additionalData;
|
|
306
|
+
_paths;
|
|
307
|
+
constructor(args) {
|
|
308
|
+
this._paths = args?.paths ?? {};
|
|
309
|
+
this._additionalData = args?.additionalData ?? {};
|
|
310
|
+
}
|
|
311
|
+
get paths() {
|
|
312
|
+
return this._paths;
|
|
313
|
+
}
|
|
314
|
+
get additionalData() {
|
|
315
|
+
return this._additionalData;
|
|
316
|
+
}
|
|
317
|
+
setPaths(paths) {
|
|
318
|
+
return new _CompilerOptions({
|
|
319
|
+
paths,
|
|
320
|
+
additionalData: this._additionalData
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
format() {
|
|
324
|
+
const json = {
|
|
325
|
+
paths: this._paths,
|
|
326
|
+
...this._additionalData
|
|
327
|
+
};
|
|
328
|
+
const ordered = (0, import_core2.sortKeys)(json, compareKeys);
|
|
329
|
+
return JSON.stringify(ordered, null, 2);
|
|
330
|
+
}
|
|
331
|
+
equals(other) {
|
|
332
|
+
if (other instanceof _CompilerOptions) {
|
|
333
|
+
return (0, import_lodash2.isEqual)(this._paths, other._paths) && (0, import_lodash2.isEqual)(this._additionalData, other._additionalData);
|
|
334
|
+
} else {
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
function compareKeys(a, b) {
|
|
340
|
+
return getKeyIndex2(a) - getKeyIndex2(b);
|
|
341
|
+
}
|
|
342
|
+
function getKeyIndex2(s) {
|
|
343
|
+
const order = [
|
|
344
|
+
"target",
|
|
345
|
+
"module",
|
|
346
|
+
"moduleResolution",
|
|
347
|
+
"esModuleInterop",
|
|
348
|
+
"lib",
|
|
349
|
+
"types",
|
|
350
|
+
"strict",
|
|
351
|
+
"allowJs"
|
|
352
|
+
];
|
|
353
|
+
if (order.every((key) => key !== s)) {
|
|
354
|
+
return Number.MAX_VALUE;
|
|
355
|
+
} else {
|
|
356
|
+
return order.indexOf(s);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// src/tsconfig/reference.ts
|
|
361
|
+
var Reference = class _Reference {
|
|
362
|
+
_path;
|
|
363
|
+
constructor(path16) {
|
|
364
|
+
this._path = path16;
|
|
365
|
+
}
|
|
366
|
+
get path() {
|
|
367
|
+
return this._path;
|
|
368
|
+
}
|
|
369
|
+
equals(other) {
|
|
370
|
+
if (other instanceof _Reference) {
|
|
371
|
+
return this._path === other._path;
|
|
372
|
+
} else {
|
|
373
|
+
return false;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// src/tsconfig/tsconfig.ts
|
|
379
|
+
var TSConfig = class _TSConfig {
|
|
380
|
+
_compilerOptions;
|
|
381
|
+
_references;
|
|
382
|
+
_additionalData;
|
|
383
|
+
constructor(args) {
|
|
384
|
+
this._compilerOptions = args?.compilerOptions ?? new CompilerOptions();
|
|
385
|
+
this._references = args?.references ?? [];
|
|
386
|
+
this._additionalData = args?.additionalData ?? {};
|
|
387
|
+
}
|
|
388
|
+
get compilerOptions() {
|
|
389
|
+
return this._compilerOptions;
|
|
390
|
+
}
|
|
391
|
+
addReference(reference) {
|
|
392
|
+
return new _TSConfig({
|
|
393
|
+
compilerOptions: this._compilerOptions,
|
|
394
|
+
references: [...this._references, reference],
|
|
395
|
+
additionalData: this._additionalData
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
setCompilerOptions(compilerOptions) {
|
|
399
|
+
return new _TSConfig({
|
|
400
|
+
compilerOptions,
|
|
401
|
+
references: this._references,
|
|
402
|
+
additionalData: this._additionalData
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
static parse(s) {
|
|
406
|
+
const json = JSON52.parse(s);
|
|
407
|
+
const references = _TSConfig.parseReferences(json);
|
|
408
|
+
const compilerOptions = new CompilerOptions({
|
|
409
|
+
paths: json.compilerOptions?.paths,
|
|
410
|
+
...json.compilerOptions
|
|
411
|
+
});
|
|
412
|
+
const additionalData = { ...json };
|
|
413
|
+
delete additionalData["compilerOptions"];
|
|
414
|
+
delete additionalData["references"];
|
|
415
|
+
return new _TSConfig({
|
|
416
|
+
compilerOptions,
|
|
417
|
+
references,
|
|
418
|
+
additionalData
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
static parseReferences(json) {
|
|
422
|
+
if (typeof json === "object" && json !== null && "references" in json && json.references instanceof Array) {
|
|
423
|
+
return json.references.map(
|
|
424
|
+
(r) => new Reference(r.path)
|
|
425
|
+
);
|
|
426
|
+
} else {
|
|
427
|
+
return [];
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
format() {
|
|
431
|
+
const compilerOptions = JSON52.parse(this.compilerOptions.format());
|
|
432
|
+
const json = {
|
|
433
|
+
compilerOptions,
|
|
434
|
+
references: this._references.map((r) => ({ path: r.path })),
|
|
435
|
+
...this._additionalData
|
|
436
|
+
};
|
|
437
|
+
const ordered = (0, import_core3.sortKeys)(json, compareKeys2);
|
|
438
|
+
return JSON.stringify(ordered, null, 2);
|
|
439
|
+
}
|
|
440
|
+
equals(other) {
|
|
441
|
+
if (other instanceof _TSConfig) {
|
|
442
|
+
const sameReferences = (0, import_core3.haveSameItems)(
|
|
443
|
+
this._references,
|
|
444
|
+
other._references,
|
|
445
|
+
(r1, r2) => r1.equals(r2)
|
|
446
|
+
);
|
|
447
|
+
return this._compilerOptions.equals(other._compilerOptions) && sameReferences && (0, import_lodash3.isEqual)(this._additionalData, other._additionalData);
|
|
448
|
+
} else {
|
|
449
|
+
return false;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
function compareKeys2(a, b) {
|
|
454
|
+
return getKeyIndex3(a) - getKeyIndex3(b);
|
|
455
|
+
}
|
|
456
|
+
function getKeyIndex3(s) {
|
|
457
|
+
const order = [
|
|
458
|
+
"extends",
|
|
459
|
+
"compilerOptions",
|
|
460
|
+
"include",
|
|
461
|
+
"exclude",
|
|
462
|
+
"references"
|
|
463
|
+
];
|
|
464
|
+
if (order.every((key) => key !== s)) {
|
|
465
|
+
return Number.MAX_VALUE;
|
|
466
|
+
} else {
|
|
467
|
+
return order.indexOf(s);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
287
471
|
// src/utils/workspace.ts
|
|
288
472
|
var import_promises2 = __toESM(require("fs/promises"));
|
|
289
473
|
var import_path = __toESM(require("path"));
|
|
@@ -332,8 +516,42 @@ async function getNamespace(directory = process.cwd()) {
|
|
|
332
516
|
return `@${result}`;
|
|
333
517
|
}
|
|
334
518
|
|
|
335
|
-
// src/packages
|
|
336
|
-
|
|
519
|
+
// src/link-packages.ts
|
|
520
|
+
async function linkPackages(current, target, development) {
|
|
521
|
+
await updatePackageJSON(current, target, development);
|
|
522
|
+
await updateTSConfig(current, target);
|
|
523
|
+
}
|
|
524
|
+
async function updatePackageJSON(current, target, development) {
|
|
525
|
+
const namespace = await getNamespace();
|
|
526
|
+
const packageJSON = await getDirectoryPackageJson(current.directory);
|
|
527
|
+
const updated = addDependency(packageJSON, target, development);
|
|
528
|
+
const packageJSONPath = getPackageJSONPath(current.directory);
|
|
529
|
+
await import_promises3.default.writeFile(packageJSONPath, updated.format(namespace));
|
|
530
|
+
}
|
|
531
|
+
function addDependency(packageJSON, target, development) {
|
|
532
|
+
const dependency = new Dependency(target.name, "workspace:*");
|
|
533
|
+
if (development) {
|
|
534
|
+
return packageJSON.addDevDependency(dependency);
|
|
535
|
+
} else {
|
|
536
|
+
return packageJSON.addDependency(dependency);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
async function updateTSConfig(current, target) {
|
|
540
|
+
const tsconfigPath = import_node_path2.default.join(current.directory, "tsconfig.json");
|
|
541
|
+
const tsconfigContents = await import_promises3.default.readFile(tsconfigPath, "utf8");
|
|
542
|
+
const tsconfig = TSConfig.parse(tsconfigContents);
|
|
543
|
+
const targetDirectory = import_node_path2.default.join(target.directory, "src", "index.ts");
|
|
544
|
+
const updatedPaths = {
|
|
545
|
+
...tsconfig.compilerOptions.paths,
|
|
546
|
+
[target.name]: [import_node_path2.default.relative(current.directory, targetDirectory)]
|
|
547
|
+
};
|
|
548
|
+
const updatedCompilerOptions = tsconfig.compilerOptions.setPaths(updatedPaths);
|
|
549
|
+
const updated = tsconfig.setCompilerOptions(updatedCompilerOptions);
|
|
550
|
+
await import_promises3.default.writeFile(tsconfigPath, updated.format());
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// src/packages/cli-app/create-cli-app.ts
|
|
554
|
+
var import_path2 = __toESM(require("path"));
|
|
337
555
|
|
|
338
556
|
// src/file-generator/package-json-generator.ts
|
|
339
557
|
var PackageJsonGenerator = class {
|
|
@@ -352,8 +570,8 @@ var PackageJsonGenerator = class {
|
|
|
352
570
|
};
|
|
353
571
|
|
|
354
572
|
// src/utils/package-generator.ts
|
|
355
|
-
var
|
|
356
|
-
var
|
|
573
|
+
var import_promises4 = __toESM(require("fs/promises"));
|
|
574
|
+
var import_node_path3 = __toESM(require("path"));
|
|
357
575
|
var PackageGenerator = class {
|
|
358
576
|
_root;
|
|
359
577
|
_packageJson;
|
|
@@ -365,15 +583,15 @@ var PackageGenerator = class {
|
|
|
365
583
|
}
|
|
366
584
|
async generate() {
|
|
367
585
|
const all = [this._packageJson, ...this._fileGenerators];
|
|
368
|
-
await
|
|
586
|
+
await import_promises4.default.mkdir(this._root, { recursive: true });
|
|
369
587
|
await Promise.all(all.map((gen) => this.write(gen)));
|
|
370
588
|
}
|
|
371
589
|
async write(fileGenerator) {
|
|
372
590
|
const contents = await fileGenerator.generate();
|
|
373
|
-
const filepath =
|
|
374
|
-
const directory =
|
|
375
|
-
await
|
|
376
|
-
await
|
|
591
|
+
const filepath = import_node_path3.default.join(this._root, fileGenerator.filepath);
|
|
592
|
+
const directory = import_node_path3.default.dirname(filepath);
|
|
593
|
+
await import_promises4.default.mkdir(directory, { recursive: true });
|
|
594
|
+
await import_promises4.default.writeFile(filepath, contents);
|
|
377
595
|
}
|
|
378
596
|
};
|
|
379
597
|
|
|
@@ -393,30 +611,7 @@ var FileGeneratorImp = class {
|
|
|
393
611
|
}
|
|
394
612
|
};
|
|
395
613
|
|
|
396
|
-
// src/packages/
|
|
397
|
-
var ADD_TS = `export function add(n1: number, n2: number): number {
|
|
398
|
-
return n1 + n2;
|
|
399
|
-
}
|
|
400
|
-
`;
|
|
401
|
-
var ADD_FILE_GENERATOR = new FileGeneratorImp("src/add.ts", ADD_TS);
|
|
402
|
-
|
|
403
|
-
// src/packages/library-package/files/add-spec-file-generator.ts
|
|
404
|
-
var ADD_SPEC_TS = `import { describe, it, expect } from 'vitest';
|
|
405
|
-
|
|
406
|
-
import { add } from '../add';
|
|
407
|
-
|
|
408
|
-
describe('add', () => {
|
|
409
|
-
it('adds two numbers', () => {
|
|
410
|
-
expect(add(2, 3)).toBe(5);
|
|
411
|
-
});
|
|
412
|
-
});
|
|
413
|
-
`;
|
|
414
|
-
var ADD_SPEC_FILE_GENERATOR = new FileGeneratorImp(
|
|
415
|
-
"src/spec/add.spec.ts",
|
|
416
|
-
ADD_SPEC_TS
|
|
417
|
-
);
|
|
418
|
-
|
|
419
|
-
// src/packages/library-package/files/eslint-config-file-generator.ts
|
|
614
|
+
// src/packages/cli-app/files/eslint-config-file-generator.ts
|
|
420
615
|
var ESLINT_CONFIG = `import base from '@stack-dev/eslint-config/base.mjs';
|
|
421
616
|
|
|
422
617
|
export default [...base, { ignores: ['**/dist/**'] }];
|
|
@@ -426,25 +621,40 @@ var ESLINT_CONFIG_FILE_GENERATOR = new FileGeneratorImp(
|
|
|
426
621
|
ESLINT_CONFIG
|
|
427
622
|
);
|
|
428
623
|
|
|
429
|
-
// src/packages/
|
|
430
|
-
var
|
|
431
|
-
`;
|
|
432
|
-
var INDEX_FILE_GENERATOR = new FileGeneratorImp(
|
|
433
|
-
"src/index.ts",
|
|
434
|
-
INDEX_TS
|
|
435
|
-
);
|
|
624
|
+
// src/packages/cli-app/files/index-file-generator.ts
|
|
625
|
+
var INDEX = `import { Command } from "commander";;
|
|
436
626
|
|
|
437
|
-
|
|
438
|
-
var PRETTIER_CONFIG = `import base from '@stack-dev/prettier-config/base.mjs';
|
|
627
|
+
const program = new Command();
|
|
439
628
|
|
|
440
|
-
|
|
441
|
-
|
|
629
|
+
program
|
|
630
|
+
.name('string-util')
|
|
631
|
+
.description('CLI to some JavaScript string utilities')
|
|
632
|
+
.version('0.8.0');
|
|
633
|
+
|
|
634
|
+
program.command('split')
|
|
635
|
+
.description('Split a string into substrings and display as an array')
|
|
636
|
+
.argument('<string>', 'string to split')
|
|
637
|
+
.option('--first', 'display just the first substring')
|
|
638
|
+
.option('-s, --separator <char>', 'separator character', ',')
|
|
639
|
+
.action((str, options) => {
|
|
640
|
+
const limit = options.first ? 1 : undefined;
|
|
641
|
+
console.log(str.split(options.separator, limit));
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
program.parse();`;
|
|
645
|
+
var INDEX_FILE_GENERATOR = new FileGeneratorImp("src/index.ts", INDEX);
|
|
646
|
+
|
|
647
|
+
// src/packages/cli-app/files/prettier-config-file-generator.ts
|
|
648
|
+
var PRETTIER_CONFIG = `import base from '@stack-dev/prettier-config/base.mjs';
|
|
649
|
+
|
|
650
|
+
export default base;
|
|
651
|
+
`;
|
|
442
652
|
var PRETTIER_CONFIG_FILE_GENERATOR = new FileGeneratorImp(
|
|
443
653
|
"prettier.config.mjs",
|
|
444
654
|
PRETTIER_CONFIG
|
|
445
655
|
);
|
|
446
656
|
|
|
447
|
-
// src/packages/
|
|
657
|
+
// src/packages/cli-app/files/tsconfig-file-generator.ts
|
|
448
658
|
var TSCONFIG = `{
|
|
449
659
|
"extends": "@stack-dev/typescript-config/tsconfig.base.json",
|
|
450
660
|
"compilerOptions": {
|
|
@@ -458,29 +668,26 @@ var TSCONFIG_FILE_GENERATOR = new FileGeneratorImp(
|
|
|
458
668
|
TSCONFIG
|
|
459
669
|
);
|
|
460
670
|
|
|
461
|
-
// src/packages/
|
|
462
|
-
var
|
|
671
|
+
// src/packages/cli-app/files/tsup-file-generator.ts
|
|
672
|
+
var TSUP = `import { defineConfig } from "tsup";
|
|
463
673
|
|
|
464
674
|
export default defineConfig({
|
|
465
|
-
entry: [
|
|
466
|
-
format: [
|
|
467
|
-
dts:
|
|
675
|
+
entry: ["src/index.ts"],
|
|
676
|
+
format: ["esm"],
|
|
677
|
+
dts: false,
|
|
468
678
|
sourcemap: true,
|
|
469
679
|
clean: true,
|
|
470
|
-
target:
|
|
680
|
+
target: "esnext",
|
|
471
681
|
outExtension({ format }) {
|
|
472
682
|
return {
|
|
473
|
-
js: format ===
|
|
683
|
+
js: format === "esm" ? ".mjs" : ".js",
|
|
474
684
|
};
|
|
475
685
|
},
|
|
476
686
|
});
|
|
477
687
|
`;
|
|
478
|
-
var
|
|
479
|
-
"tsup.config.ts",
|
|
480
|
-
TSUP_CONFIG
|
|
481
|
-
);
|
|
688
|
+
var TSUP_FILE_GENERATOR = new FileGeneratorImp("tsup.config.ts", TSUP);
|
|
482
689
|
|
|
483
|
-
// src/packages/
|
|
690
|
+
// src/packages/cli-app/files/vitest-config-file-generator.ts
|
|
484
691
|
var VITEST_CONFIG = `import { defineConfig } from 'vitest/config';
|
|
485
692
|
|
|
486
693
|
export default defineConfig({
|
|
@@ -498,193 +705,220 @@ var VITEST_CONFIG_FILE_GENERATOR = new FileGeneratorImp(
|
|
|
498
705
|
VITEST_CONFIG
|
|
499
706
|
);
|
|
500
707
|
|
|
501
|
-
// src/packages/
|
|
502
|
-
async function
|
|
708
|
+
// src/packages/cli-app/create-cli-app.ts
|
|
709
|
+
async function createCliApp(name) {
|
|
503
710
|
const rootDir = await getWorkspaceRoot();
|
|
504
|
-
const directory =
|
|
711
|
+
const directory = import_path2.default.join(rootDir, "apps", name);
|
|
505
712
|
const namespace = await getNamespace(rootDir);
|
|
506
713
|
const packageName = `${namespace}/${name}`;
|
|
507
|
-
console.log(`\
|
|
714
|
+
console.log(`\u{1F680} Creating CLI App: ${packageName}`);
|
|
508
715
|
const generator = new PackageGenerator(
|
|
509
716
|
directory,
|
|
510
|
-
|
|
717
|
+
makeAppPackageGenerator(packageName, namespace),
|
|
511
718
|
[
|
|
512
719
|
INDEX_FILE_GENERATOR,
|
|
513
|
-
ADD_FILE_GENERATOR,
|
|
514
|
-
ADD_SPEC_FILE_GENERATOR,
|
|
515
|
-
TSUP_CONFIG_FILE_GENERATOR,
|
|
516
720
|
TSCONFIG_FILE_GENERATOR,
|
|
721
|
+
TSUP_FILE_GENERATOR,
|
|
517
722
|
PRETTIER_CONFIG_FILE_GENERATOR,
|
|
518
723
|
ESLINT_CONFIG_FILE_GENERATOR,
|
|
519
724
|
VITEST_CONFIG_FILE_GENERATOR
|
|
520
725
|
]
|
|
521
726
|
);
|
|
522
727
|
await generator.generate();
|
|
523
|
-
console.log(`\u2705 Config package created at: ${directory}`);
|
|
524
728
|
}
|
|
525
|
-
function
|
|
729
|
+
function makeAppPackageGenerator(packageName, namespace) {
|
|
526
730
|
const packageJsonModel = new PackageJSON({
|
|
527
731
|
name: packageName,
|
|
732
|
+
peerDependencies: [
|
|
733
|
+
new Dependency("typescript", "^5.9.3"),
|
|
734
|
+
new Dependency("@types/node", "^25.0.3")
|
|
735
|
+
],
|
|
736
|
+
dependencies: [new Dependency("commander", "14.0.2")],
|
|
528
737
|
devDependencies: [
|
|
529
738
|
new Dependency(`${namespace}/eslint-config`, "workspace:*"),
|
|
530
739
|
new Dependency(`${namespace}/prettier-config`, "workspace:*"),
|
|
531
740
|
new Dependency(`${namespace}/typescript-config`, "workspace:*"),
|
|
741
|
+
new Dependency("tsup", "^8.5.1"),
|
|
742
|
+
new Dependency("tsx", "^4.21.0"),
|
|
532
743
|
new Dependency("eslint", "^9.32.0"),
|
|
533
744
|
new Dependency("prettier", "^3.6.2"),
|
|
534
|
-
new Dependency("
|
|
535
|
-
new Dependency("tsup", "^7.3.0"),
|
|
536
|
-
new Dependency("vitest", "^3.2.4"),
|
|
537
|
-
new Dependency("@vitest/coverage-v8", "^3.2.4")
|
|
745
|
+
new Dependency("vitest", "^3.2.4")
|
|
538
746
|
],
|
|
539
747
|
additionalData: {
|
|
540
748
|
version: "0.1.0",
|
|
541
749
|
private: true,
|
|
542
|
-
|
|
543
|
-
module: "dist/index.mjs",
|
|
544
|
-
types: "dist/index.d.ts",
|
|
545
|
-
exports: {
|
|
546
|
-
".": {
|
|
547
|
-
development: "./src/index.ts",
|
|
548
|
-
import: "./dist/index.mjs",
|
|
549
|
-
require: "./dist/index.js",
|
|
550
|
-
types: "./dist/index.d.ts"
|
|
551
|
-
}
|
|
552
|
-
},
|
|
750
|
+
type: "module",
|
|
553
751
|
scripts: {
|
|
554
|
-
|
|
555
|
-
|
|
752
|
+
dev: "tsx watch src/index.ts",
|
|
753
|
+
build: "tsup src/index.ts",
|
|
754
|
+
start: "node dist/index.mjs",
|
|
755
|
+
lint: "eslint .",
|
|
556
756
|
format: "prettier . --write",
|
|
557
757
|
test: "vitest run",
|
|
558
758
|
"test:watch": "vitest"
|
|
559
|
-
}
|
|
560
|
-
sideEffects: false
|
|
759
|
+
}
|
|
561
760
|
}
|
|
562
761
|
});
|
|
563
762
|
return new PackageJsonGenerator(packageJsonModel, namespace);
|
|
564
763
|
}
|
|
565
764
|
|
|
566
|
-
// src/packages/
|
|
567
|
-
|
|
568
|
-
throw new Error("Not implemented.");
|
|
569
|
-
}
|
|
570
|
-
var STYLED_BUTTON = `import React from 'react';
|
|
765
|
+
// src/packages/fastify-app/create-fastify-app.ts
|
|
766
|
+
var import_path3 = __toESM(require("path"));
|
|
571
767
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
onClick?: () => void;
|
|
575
|
-
}
|
|
768
|
+
// src/packages/fastify-app/files/eslint-config-file-generator.ts
|
|
769
|
+
var ESLINT_CONFIG2 = `import base from '@stack-dev/eslint-config/base.mjs';
|
|
576
770
|
|
|
577
|
-
export
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
onClick={onClick}
|
|
583
|
-
className="my-lib-bg-blue-600 my-lib-text-white my-lib-p-[10px] my-lib-border-none my-lib-rounded my-lib-cursor-pointer hover:my-lib-brightness-110"
|
|
584
|
-
>
|
|
585
|
-
{label}
|
|
586
|
-
</button>
|
|
587
|
-
);
|
|
588
|
-
};`;
|
|
589
|
-
var STYLED_BUTTON_FILE_GENERATOR = new FileGeneratorImp(
|
|
590
|
-
"styled-button.ts",
|
|
591
|
-
STYLED_BUTTON
|
|
771
|
+
export default [...base, { ignores: ['**/dist/**'] }];
|
|
772
|
+
`;
|
|
773
|
+
var ESLINT_CONFIG_FILE_GENERATOR2 = new FileGeneratorImp(
|
|
774
|
+
"eslint.config.mjs",
|
|
775
|
+
ESLINT_CONFIG2
|
|
592
776
|
);
|
|
593
777
|
|
|
594
|
-
// src/packages/
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
778
|
+
// src/packages/fastify-app/files/index-file-generator.ts
|
|
779
|
+
var INDEX2 = `import Fastify from "fastify";
|
|
780
|
+
import fastifySwagger from "@fastify/swagger";
|
|
781
|
+
import fastifySwaggerUI from "@fastify/swagger-ui";
|
|
598
782
|
|
|
599
|
-
|
|
600
|
-
|
|
783
|
+
const fastify = Fastify({
|
|
784
|
+
logger: {
|
|
785
|
+
transport: {
|
|
786
|
+
target: "pino-pretty",
|
|
787
|
+
},
|
|
788
|
+
serializers: {
|
|
789
|
+
res(reply) {
|
|
790
|
+
// The default
|
|
791
|
+
return {
|
|
792
|
+
statusCode: reply.statusCode,
|
|
793
|
+
};
|
|
794
|
+
},
|
|
795
|
+
req(request) {
|
|
796
|
+
return {
|
|
797
|
+
method: request.method,
|
|
798
|
+
url: request.url,
|
|
799
|
+
path: request.routeOptions.url,
|
|
800
|
+
parameters: request.params,
|
|
801
|
+
// Including headers in the log could violate privacy laws,
|
|
802
|
+
// e.g., GDPR. Use the "redact" option to remove sensitive
|
|
803
|
+
// fields. It could also leak authentication data in the logs.
|
|
804
|
+
headers: request.headers,
|
|
805
|
+
};
|
|
806
|
+
},
|
|
807
|
+
},
|
|
808
|
+
},
|
|
809
|
+
});
|
|
601
810
|
|
|
602
|
-
|
|
603
|
-
var BUTTON_CSS_MODULE = `.styledButton {
|
|
604
|
-
background: blue;
|
|
605
|
-
color: white;
|
|
606
|
-
padding: 10px;
|
|
607
|
-
border: none;
|
|
608
|
-
border-radius: 4px;
|
|
609
|
-
cursor: pointer;
|
|
610
|
-
}
|
|
611
|
-
`;
|
|
612
|
-
var BUTTON_CSS_MODULE_FILE_GENERATOR = new FileGeneratorImp(
|
|
613
|
-
"src/button.module.css",
|
|
614
|
-
BUTTON_CSS_MODULE
|
|
615
|
-
);
|
|
811
|
+
await registerSwagger();
|
|
616
812
|
|
|
617
|
-
|
|
618
|
-
var BUTTON = `import React from 'react';
|
|
619
|
-
import * as styles from './button.module.css';
|
|
813
|
+
registerRoutes();
|
|
620
814
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
var BUTTON_FILE_GENERATOR = new FileGeneratorImp(
|
|
626
|
-
"src/button.tsx",
|
|
627
|
-
BUTTON
|
|
628
|
-
);
|
|
815
|
+
function registerRoutes() {
|
|
816
|
+
fastify.get("/", async (request, reply) => {
|
|
817
|
+
return { hello: "world", docs: "/docs" };
|
|
818
|
+
});
|
|
629
819
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
820
|
+
fastify.get<{
|
|
821
|
+
Params: { a: string; b: string };
|
|
822
|
+
}>(
|
|
823
|
+
"/add/:a/:b",
|
|
824
|
+
{
|
|
825
|
+
schema: {
|
|
826
|
+
params: {
|
|
827
|
+
type: "object",
|
|
828
|
+
properties: {
|
|
829
|
+
a: { type: "string" },
|
|
830
|
+
b: { type: "string" },
|
|
831
|
+
},
|
|
832
|
+
required: ["a", "b"],
|
|
833
|
+
},
|
|
834
|
+
response: {
|
|
835
|
+
200: {
|
|
836
|
+
type: "object",
|
|
837
|
+
properties: {
|
|
838
|
+
result: { type: "number" },
|
|
839
|
+
},
|
|
840
|
+
},
|
|
841
|
+
},
|
|
842
|
+
},
|
|
843
|
+
},
|
|
844
|
+
async (request, reply) => {
|
|
845
|
+
// request.params.a should now be recognized as a string
|
|
846
|
+
const a = Number(request.params.a);
|
|
847
|
+
const b = Number(request.params.b);
|
|
633
848
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
});
|
|
849
|
+
return { result: a + b };
|
|
850
|
+
}
|
|
851
|
+
);
|
|
852
|
+
}
|
|
639
853
|
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
854
|
+
async function registerSwagger() {
|
|
855
|
+
await fastify.register(fastifySwagger, {
|
|
856
|
+
openapi: {
|
|
857
|
+
openapi: "3.0.0",
|
|
858
|
+
info: {
|
|
859
|
+
title: "Test swagger",
|
|
860
|
+
description: "Testing the Fastify swagger API",
|
|
861
|
+
version: "0.1.0",
|
|
862
|
+
},
|
|
863
|
+
servers: [
|
|
864
|
+
{
|
|
865
|
+
url: "http://localhost:3000",
|
|
866
|
+
description: "Development server",
|
|
867
|
+
},
|
|
868
|
+
],
|
|
869
|
+
components: {
|
|
870
|
+
securitySchemes: {
|
|
871
|
+
apiKey: {
|
|
872
|
+
type: "apiKey",
|
|
873
|
+
name: "apiKey",
|
|
874
|
+
in: "header",
|
|
875
|
+
},
|
|
876
|
+
},
|
|
877
|
+
},
|
|
878
|
+
externalDocs: {
|
|
879
|
+
url: "https://swagger.io",
|
|
880
|
+
description: "Find more info here",
|
|
881
|
+
},
|
|
882
|
+
},
|
|
644
883
|
});
|
|
645
884
|
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
885
|
+
await fastify.register(fastifySwaggerUI, {
|
|
886
|
+
routePrefix: "/docs",
|
|
887
|
+
uiConfig: {
|
|
888
|
+
docExpansion: "list",
|
|
889
|
+
deepLinking: false,
|
|
890
|
+
},
|
|
891
|
+
uiHooks: {
|
|
892
|
+
onRequest: function (request, reply, next) {
|
|
893
|
+
next();
|
|
894
|
+
},
|
|
895
|
+
preHandler: function (request, reply, next) {
|
|
896
|
+
next();
|
|
897
|
+
},
|
|
898
|
+
},
|
|
899
|
+
staticCSP: true,
|
|
900
|
+
transformStaticCSP: (header) => header,
|
|
901
|
+
transformSpecification: (swaggerObject, request, reply) => {
|
|
902
|
+
return swaggerObject;
|
|
903
|
+
},
|
|
904
|
+
transformSpecificationClone: true,
|
|
654
905
|
});
|
|
655
|
-
}
|
|
656
|
-
`;
|
|
657
|
-
var BUTTON_SPEC_FILE_GENERATOR = new FileGeneratorImp(
|
|
658
|
-
"src/button.spec.tsx",
|
|
659
|
-
BUTTON_SPEC
|
|
660
|
-
);
|
|
661
|
-
|
|
662
|
-
// src/packages/react-package/css-react-package/files/eslint-config-file-generator.ts
|
|
663
|
-
var ESLINT_CONFIG2 = `import base from '@stack-dev/eslint-config/base.mjs';
|
|
664
|
-
import react from '@stack-dev/eslint-config/react.mjs';
|
|
906
|
+
}
|
|
665
907
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
{
|
|
670
|
-
|
|
908
|
+
async function start() {
|
|
909
|
+
try {
|
|
910
|
+
await fastify.listen({ port: 3000 });
|
|
911
|
+
} catch (err) {
|
|
912
|
+
fastify.log.error(err);
|
|
913
|
+
process.exit(1);
|
|
671
914
|
}
|
|
672
|
-
|
|
673
|
-
`;
|
|
674
|
-
var ESLINT_CONFIG_FILE_GENERATOR2 = new FileGeneratorImp(
|
|
675
|
-
"eslint.config.mjs",
|
|
676
|
-
ESLINT_CONFIG2
|
|
677
|
-
);
|
|
915
|
+
}
|
|
678
916
|
|
|
679
|
-
|
|
680
|
-
var INDEX_TS2 = `export * from './button';
|
|
917
|
+
start();
|
|
681
918
|
`;
|
|
682
|
-
var INDEX_FILE_GENERATOR2 = new FileGeneratorImp(
|
|
683
|
-
"src/index.ts",
|
|
684
|
-
INDEX_TS2
|
|
685
|
-
);
|
|
919
|
+
var INDEX_FILE_GENERATOR2 = new FileGeneratorImp("src/index.ts", INDEX2);
|
|
686
920
|
|
|
687
|
-
// src/packages/
|
|
921
|
+
// src/packages/fastify-app/files/prettier-config-file-generator.ts
|
|
688
922
|
var PRETTIER_CONFIG2 = `import base from '@stack-dev/prettier-config/base.mjs';
|
|
689
923
|
|
|
690
924
|
export default base;
|
|
@@ -694,9 +928,9 @@ var PRETTIER_CONFIG_FILE_GENERATOR2 = new FileGeneratorImp(
|
|
|
694
928
|
PRETTIER_CONFIG2
|
|
695
929
|
);
|
|
696
930
|
|
|
697
|
-
// src/packages/
|
|
931
|
+
// src/packages/fastify-app/files/tsconfig-file-generator.ts
|
|
698
932
|
var TSCONFIG2 = `{
|
|
699
|
-
"extends": "@stack-dev/typescript-config/tsconfig.
|
|
933
|
+
"extends": "@stack-dev/typescript-config/tsconfig.base.json",
|
|
700
934
|
"compilerOptions": {
|
|
701
935
|
"outDir": "dist"
|
|
702
936
|
},
|
|
@@ -708,43 +942,35 @@ var TSCONFIG_FILE_GENERATOR2 = new FileGeneratorImp(
|
|
|
708
942
|
TSCONFIG2
|
|
709
943
|
);
|
|
710
944
|
|
|
711
|
-
// src/packages/
|
|
712
|
-
var
|
|
945
|
+
// src/packages/fastify-app/files/tsup-file-generator.ts
|
|
946
|
+
var TSUP2 = `import { defineConfig } from "tsup";
|
|
713
947
|
|
|
714
948
|
export default defineConfig({
|
|
715
|
-
entry: [
|
|
716
|
-
format: [
|
|
717
|
-
dts:
|
|
718
|
-
|
|
949
|
+
entry: ["src/index.ts"],
|
|
950
|
+
format: ["esm"],
|
|
951
|
+
dts: false,
|
|
952
|
+
sourcemap: true,
|
|
719
953
|
clean: true,
|
|
720
|
-
|
|
721
|
-
external: ['react', 'react-dom'],
|
|
954
|
+
target: "esnext",
|
|
722
955
|
outExtension({ format }) {
|
|
723
956
|
return {
|
|
724
|
-
js: format ===
|
|
957
|
+
js: format === "esm" ? ".mjs" : ".js",
|
|
725
958
|
};
|
|
726
959
|
},
|
|
727
960
|
});
|
|
728
961
|
`;
|
|
729
|
-
var
|
|
730
|
-
"tsup.config.ts",
|
|
731
|
-
TSUP_CONFIG2
|
|
732
|
-
);
|
|
962
|
+
var TSUP_FILE_GENERATOR2 = new FileGeneratorImp("tsup.config.ts", TSUP2);
|
|
733
963
|
|
|
734
|
-
// src/packages/
|
|
964
|
+
// src/packages/fastify-app/files/vitest-config-file-generator.ts
|
|
735
965
|
var VITEST_CONFIG2 = `import { defineConfig } from 'vitest/config';
|
|
736
|
-
import react from '@vitejs/plugin-react';
|
|
737
966
|
|
|
738
967
|
export default defineConfig({
|
|
739
|
-
plugins: [react()],
|
|
740
968
|
test: {
|
|
741
969
|
globals: true,
|
|
742
|
-
environment: 'jsdom',
|
|
743
970
|
coverage: {
|
|
744
971
|
provider: 'v8',
|
|
745
|
-
reporter: ['text', 'json', 'html'],
|
|
746
972
|
},
|
|
747
|
-
|
|
973
|
+
environment: 'node',
|
|
748
974
|
},
|
|
749
975
|
});
|
|
750
976
|
`;
|
|
@@ -753,126 +979,278 @@ var VITEST_CONFIG_FILE_GENERATOR2 = new FileGeneratorImp(
|
|
|
753
979
|
VITEST_CONFIG2
|
|
754
980
|
);
|
|
755
981
|
|
|
756
|
-
// src/packages/
|
|
757
|
-
async function
|
|
982
|
+
// src/packages/fastify-app/create-fastify-app.ts
|
|
983
|
+
async function createFastifyApp(name) {
|
|
758
984
|
const rootDir = await getWorkspaceRoot();
|
|
759
|
-
const directory =
|
|
985
|
+
const directory = import_path3.default.join(rootDir, "apps", name);
|
|
760
986
|
const namespace = await getNamespace(rootDir);
|
|
761
987
|
const packageName = `${namespace}/${name}`;
|
|
762
|
-
console.log(`\
|
|
988
|
+
console.log(`\u{1F680} Creating Fastify App: ${packageName}`);
|
|
763
989
|
const generator = new PackageGenerator(
|
|
764
990
|
directory,
|
|
765
|
-
|
|
991
|
+
makeAppPackageGenerator2(packageName, namespace),
|
|
766
992
|
[
|
|
767
993
|
INDEX_FILE_GENERATOR2,
|
|
768
|
-
BUTTON_FILE_GENERATOR,
|
|
769
|
-
BUTTON_CSS_MODULE_FILE_GENERATOR,
|
|
770
|
-
BUTTON_SPEC_FILE_GENERATOR,
|
|
771
|
-
TSUP_CONFIG_FILE_GENERATOR2,
|
|
772
994
|
TSCONFIG_FILE_GENERATOR2,
|
|
995
|
+
TSUP_FILE_GENERATOR2,
|
|
773
996
|
PRETTIER_CONFIG_FILE_GENERATOR2,
|
|
774
997
|
ESLINT_CONFIG_FILE_GENERATOR2,
|
|
775
998
|
VITEST_CONFIG_FILE_GENERATOR2
|
|
776
999
|
]
|
|
777
1000
|
);
|
|
778
1001
|
await generator.generate();
|
|
779
|
-
console.log(`\u2705 Library created at: ${directory}`);
|
|
780
1002
|
}
|
|
781
|
-
function
|
|
1003
|
+
function makeAppPackageGenerator2(packageName, namespace) {
|
|
782
1004
|
const packageJsonModel = new PackageJSON({
|
|
783
1005
|
name: packageName,
|
|
784
1006
|
peerDependencies: [
|
|
785
|
-
new Dependency("
|
|
786
|
-
new Dependency("
|
|
1007
|
+
new Dependency("typescript", "^5.9.3"),
|
|
1008
|
+
new Dependency("@types/node", "^25.0.3")
|
|
1009
|
+
],
|
|
1010
|
+
dependencies: [
|
|
1011
|
+
new Dependency("fastify", "^5.6.2"),
|
|
1012
|
+
new Dependency("@fastify/swagger", "^9.6.1"),
|
|
1013
|
+
new Dependency("@fastify/swagger-ui", "^5.2.3"),
|
|
1014
|
+
new Dependency("pino-pretty", "^13.1.3")
|
|
787
1015
|
],
|
|
788
1016
|
devDependencies: [
|
|
789
1017
|
new Dependency(`${namespace}/eslint-config`, "workspace:*"),
|
|
790
1018
|
new Dependency(`${namespace}/prettier-config`, "workspace:*"),
|
|
791
1019
|
new Dependency(`${namespace}/typescript-config`, "workspace:*"),
|
|
792
|
-
|
|
793
|
-
new Dependency("
|
|
794
|
-
new Dependency("react-dom", "^18.3.1"),
|
|
795
|
-
new Dependency("@types/react", "^18.3.1"),
|
|
796
|
-
new Dependency("@types/react-dom", "^18.3.1"),
|
|
797
|
-
// Linting & Formatting
|
|
1020
|
+
new Dependency("tsup", "^8.5.1"),
|
|
1021
|
+
new Dependency("tsx", "^4.21.0"),
|
|
798
1022
|
new Dependency("eslint", "^9.32.0"),
|
|
799
1023
|
new Dependency("prettier", "^3.6.2"),
|
|
800
|
-
new Dependency("
|
|
801
|
-
// Build
|
|
802
|
-
new Dependency("tsup", "^8.0.0"),
|
|
803
|
-
new Dependency("postcss", "^8.4.0"),
|
|
804
|
-
// Testing
|
|
805
|
-
new Dependency("vitest", "^3.2.4"),
|
|
806
|
-
new Dependency("@vitest/coverage-v8", "^3.2.4"),
|
|
807
|
-
new Dependency("@testing-library/react", "^16.0.0"),
|
|
808
|
-
new Dependency("@testing-library/jest-dom", "^6.0.0"),
|
|
809
|
-
new Dependency("jsdom", "^25.0.0")
|
|
1024
|
+
new Dependency("vitest", "^3.2.4")
|
|
810
1025
|
],
|
|
811
1026
|
additionalData: {
|
|
812
1027
|
version: "0.1.0",
|
|
813
1028
|
private: true,
|
|
814
|
-
|
|
815
|
-
module: "dist/index.mjs",
|
|
816
|
-
types: "dist/index.d.ts",
|
|
817
|
-
exports: {
|
|
818
|
-
".": {
|
|
819
|
-
development: "./src/index.ts",
|
|
820
|
-
import: "./dist/index.mjs",
|
|
821
|
-
require: "./dist/index.js",
|
|
822
|
-
types: "./dist/index.d.ts"
|
|
823
|
-
},
|
|
824
|
-
"./index.css": "./dist/index.css"
|
|
825
|
-
},
|
|
1029
|
+
type: "module",
|
|
826
1030
|
scripts: {
|
|
827
|
-
|
|
1031
|
+
dev: "tsx watch src/index.ts",
|
|
1032
|
+
build: "tsup src/index.ts",
|
|
1033
|
+
start: "node dist/index.mjs",
|
|
828
1034
|
lint: "eslint .",
|
|
829
1035
|
format: "prettier . --write",
|
|
830
1036
|
test: "vitest run",
|
|
831
1037
|
"test:watch": "vitest"
|
|
832
|
-
}
|
|
833
|
-
sideEffects: ["**/*.css"]
|
|
1038
|
+
}
|
|
834
1039
|
}
|
|
835
1040
|
});
|
|
836
1041
|
return new PackageJsonGenerator(packageJsonModel, namespace);
|
|
837
1042
|
}
|
|
838
1043
|
|
|
839
|
-
// src/packages/
|
|
840
|
-
var
|
|
841
|
-
|
|
842
|
-
// src/packages/react-package/styled-components-react-package/files/button-file-generator.ts
|
|
843
|
-
var BUTTON2 = `import React, { HTMLAttributes } from 'react';
|
|
844
|
-
import styled from 'styled-components';
|
|
845
|
-
|
|
846
|
-
// This is your "Styled" version of the button
|
|
847
|
-
// No more imports, no more "empty objects"
|
|
848
|
-
const StyledButton = styled.button\`
|
|
849
|
-
background-color: #007bff;
|
|
850
|
-
color: white;
|
|
851
|
-
padding: 10px 20px;
|
|
852
|
-
border: none;
|
|
853
|
-
border-radius: 4px;
|
|
854
|
-
cursor: pointer;
|
|
855
|
-
font-size: 16px;
|
|
856
|
-
|
|
857
|
-
&:hover {
|
|
858
|
-
background-color: #0056b3;
|
|
859
|
-
}
|
|
860
|
-
\`;
|
|
1044
|
+
// src/packages/library-package/create-library-package.ts
|
|
1045
|
+
var import_node_path4 = __toESM(require("path"));
|
|
861
1046
|
|
|
862
|
-
|
|
863
|
-
|
|
1047
|
+
// src/packages/library-package/files/add-file-generator.ts
|
|
1048
|
+
var ADD_TS = `export function add(n1: number, n2: number): number {
|
|
1049
|
+
return n1 + n2;
|
|
864
1050
|
}
|
|
865
1051
|
`;
|
|
866
|
-
var
|
|
867
|
-
"src/button.tsx",
|
|
868
|
-
BUTTON2
|
|
869
|
-
);
|
|
1052
|
+
var ADD_FILE_GENERATOR = new FileGeneratorImp("src/add.ts", ADD_TS);
|
|
870
1053
|
|
|
871
|
-
// src/packages/
|
|
872
|
-
var
|
|
873
|
-
import { Button } from './button';
|
|
1054
|
+
// src/packages/library-package/files/add-spec-file-generator.ts
|
|
1055
|
+
var ADD_SPEC_TS = `import { describe, it, expect } from 'vitest';
|
|
874
1056
|
|
|
875
|
-
|
|
1057
|
+
import { add } from '../add';
|
|
1058
|
+
|
|
1059
|
+
describe('add', () => {
|
|
1060
|
+
it('adds two numbers', () => {
|
|
1061
|
+
expect(add(2, 3)).toBe(5);
|
|
1062
|
+
});
|
|
1063
|
+
});
|
|
1064
|
+
`;
|
|
1065
|
+
var ADD_SPEC_FILE_GENERATOR = new FileGeneratorImp(
|
|
1066
|
+
"src/spec/add.spec.ts",
|
|
1067
|
+
ADD_SPEC_TS
|
|
1068
|
+
);
|
|
1069
|
+
|
|
1070
|
+
// src/packages/library-package/files/eslint-config-file-generator.ts
|
|
1071
|
+
var ESLINT_CONFIG3 = `import base from '@stack-dev/eslint-config/base.mjs';
|
|
1072
|
+
|
|
1073
|
+
export default [...base, { ignores: ['**/dist/**'] }];
|
|
1074
|
+
`;
|
|
1075
|
+
var ESLINT_CONFIG_FILE_GENERATOR3 = new FileGeneratorImp(
|
|
1076
|
+
"eslint.config.mjs",
|
|
1077
|
+
ESLINT_CONFIG3
|
|
1078
|
+
);
|
|
1079
|
+
|
|
1080
|
+
// src/packages/library-package/files/index-file-generator.ts
|
|
1081
|
+
var INDEX_TS = `export * from './add';
|
|
1082
|
+
`;
|
|
1083
|
+
var INDEX_FILE_GENERATOR3 = new FileGeneratorImp(
|
|
1084
|
+
"src/index.ts",
|
|
1085
|
+
INDEX_TS
|
|
1086
|
+
);
|
|
1087
|
+
|
|
1088
|
+
// src/packages/library-package/files/prettier-config-file-generator.ts
|
|
1089
|
+
var PRETTIER_CONFIG3 = `import base from '@stack-dev/prettier-config/base.mjs';
|
|
1090
|
+
|
|
1091
|
+
export default base;
|
|
1092
|
+
`;
|
|
1093
|
+
var PRETTIER_CONFIG_FILE_GENERATOR3 = new FileGeneratorImp(
|
|
1094
|
+
"prettier.config.mjs",
|
|
1095
|
+
PRETTIER_CONFIG3
|
|
1096
|
+
);
|
|
1097
|
+
|
|
1098
|
+
// src/packages/library-package/files/tsconfig-file-generator.ts
|
|
1099
|
+
var TSCONFIG3 = `{
|
|
1100
|
+
"extends": "@stack-dev/typescript-config/tsconfig.base.json",
|
|
1101
|
+
"compilerOptions": {
|
|
1102
|
+
"outDir": "dist"
|
|
1103
|
+
},
|
|
1104
|
+
"include": ["src"]
|
|
1105
|
+
}
|
|
1106
|
+
`;
|
|
1107
|
+
var TSCONFIG_FILE_GENERATOR3 = new FileGeneratorImp(
|
|
1108
|
+
"tsconfig.json",
|
|
1109
|
+
TSCONFIG3
|
|
1110
|
+
);
|
|
1111
|
+
|
|
1112
|
+
// src/packages/library-package/files/tsup-config-file-generator.ts
|
|
1113
|
+
var TSUP_CONFIG = `import { defineConfig } from 'tsup';
|
|
1114
|
+
|
|
1115
|
+
export default defineConfig({
|
|
1116
|
+
entry: ['src/index.ts'],
|
|
1117
|
+
format: ['esm', 'cjs'],
|
|
1118
|
+
dts: true,
|
|
1119
|
+
sourcemap: true,
|
|
1120
|
+
clean: true,
|
|
1121
|
+
target: 'esnext',
|
|
1122
|
+
outExtension({ format }) {
|
|
1123
|
+
return {
|
|
1124
|
+
js: format === 'esm' ? '.mjs' : '.js',
|
|
1125
|
+
};
|
|
1126
|
+
},
|
|
1127
|
+
});
|
|
1128
|
+
`;
|
|
1129
|
+
var TSUP_CONFIG_FILE_GENERATOR = new FileGeneratorImp(
|
|
1130
|
+
"tsup.config.ts",
|
|
1131
|
+
TSUP_CONFIG
|
|
1132
|
+
);
|
|
1133
|
+
|
|
1134
|
+
// src/packages/library-package/files/vitest-config-file-generator.ts
|
|
1135
|
+
var VITEST_CONFIG3 = `import { defineConfig } from 'vitest/config';
|
|
1136
|
+
|
|
1137
|
+
export default defineConfig({
|
|
1138
|
+
test: {
|
|
1139
|
+
globals: true,
|
|
1140
|
+
coverage: {
|
|
1141
|
+
provider: 'v8',
|
|
1142
|
+
},
|
|
1143
|
+
environment: 'node',
|
|
1144
|
+
},
|
|
1145
|
+
});
|
|
1146
|
+
`;
|
|
1147
|
+
var VITEST_CONFIG_FILE_GENERATOR3 = new FileGeneratorImp(
|
|
1148
|
+
"vitest.config.ts",
|
|
1149
|
+
VITEST_CONFIG3
|
|
1150
|
+
);
|
|
1151
|
+
|
|
1152
|
+
// src/packages/library-package/create-library-package.ts
|
|
1153
|
+
async function createLibraryPackage(name) {
|
|
1154
|
+
const rootDir = await getWorkspaceRoot();
|
|
1155
|
+
const directory = import_node_path4.default.join(rootDir, "packages", name);
|
|
1156
|
+
const namespace = await getNamespace(rootDir);
|
|
1157
|
+
const packageName = `${namespace}/${name}`;
|
|
1158
|
+
console.log(`\u2728 Creating config package: ${packageName}`);
|
|
1159
|
+
const generator = new PackageGenerator(
|
|
1160
|
+
directory,
|
|
1161
|
+
makePackageGenerator(packageName, namespace),
|
|
1162
|
+
[
|
|
1163
|
+
INDEX_FILE_GENERATOR3,
|
|
1164
|
+
ADD_FILE_GENERATOR,
|
|
1165
|
+
ADD_SPEC_FILE_GENERATOR,
|
|
1166
|
+
TSUP_CONFIG_FILE_GENERATOR,
|
|
1167
|
+
TSCONFIG_FILE_GENERATOR3,
|
|
1168
|
+
PRETTIER_CONFIG_FILE_GENERATOR3,
|
|
1169
|
+
ESLINT_CONFIG_FILE_GENERATOR3,
|
|
1170
|
+
VITEST_CONFIG_FILE_GENERATOR3
|
|
1171
|
+
]
|
|
1172
|
+
);
|
|
1173
|
+
await generator.generate();
|
|
1174
|
+
console.log(`\u2705 Config package created at: ${directory}`);
|
|
1175
|
+
}
|
|
1176
|
+
function makePackageGenerator(packageName, namespace) {
|
|
1177
|
+
const packageJsonModel = new PackageJSON({
|
|
1178
|
+
name: packageName,
|
|
1179
|
+
devDependencies: [
|
|
1180
|
+
new Dependency(`${namespace}/eslint-config`, "workspace:*"),
|
|
1181
|
+
new Dependency(`${namespace}/prettier-config`, "workspace:*"),
|
|
1182
|
+
new Dependency(`${namespace}/typescript-config`, "workspace:*"),
|
|
1183
|
+
new Dependency("eslint", "^9.32.0"),
|
|
1184
|
+
new Dependency("prettier", "^3.6.2"),
|
|
1185
|
+
new Dependency("prettier-plugin-organize-imports", "^4.2.0"),
|
|
1186
|
+
new Dependency("tsup", "^7.3.0"),
|
|
1187
|
+
new Dependency("vitest", "^3.2.4"),
|
|
1188
|
+
new Dependency("@vitest/coverage-v8", "^3.2.4")
|
|
1189
|
+
],
|
|
1190
|
+
additionalData: {
|
|
1191
|
+
version: "0.1.0",
|
|
1192
|
+
private: true,
|
|
1193
|
+
main: "dist/index.js",
|
|
1194
|
+
module: "dist/index.mjs",
|
|
1195
|
+
types: "dist/index.d.ts",
|
|
1196
|
+
exports: {
|
|
1197
|
+
".": {
|
|
1198
|
+
development: "./src/index.ts",
|
|
1199
|
+
import: "./dist/index.mjs",
|
|
1200
|
+
require: "./dist/index.js",
|
|
1201
|
+
types: "./dist/index.d.ts"
|
|
1202
|
+
}
|
|
1203
|
+
},
|
|
1204
|
+
scripts: {
|
|
1205
|
+
build: "tsup",
|
|
1206
|
+
lint: "eslint",
|
|
1207
|
+
format: "prettier . --write",
|
|
1208
|
+
test: "vitest run",
|
|
1209
|
+
"test:watch": "vitest"
|
|
1210
|
+
},
|
|
1211
|
+
sideEffects: false
|
|
1212
|
+
}
|
|
1213
|
+
});
|
|
1214
|
+
return new PackageJsonGenerator(packageJsonModel, namespace);
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
// src/packages/react-package/styled-components-react-package/create-styled-components-react-package.ts
|
|
1218
|
+
var import_path4 = __toESM(require("path"));
|
|
1219
|
+
|
|
1220
|
+
// src/packages/react-package/styled-components-react-package/files/button-file-generator.ts
|
|
1221
|
+
var BUTTON = `import React, { HTMLAttributes } from 'react';
|
|
1222
|
+
import styled from 'styled-components';
|
|
1223
|
+
|
|
1224
|
+
// This is your "Styled" version of the button
|
|
1225
|
+
// No more imports, no more "empty objects"
|
|
1226
|
+
const StyledButton = styled.button\`
|
|
1227
|
+
background-color: #007bff;
|
|
1228
|
+
color: white;
|
|
1229
|
+
padding: 10px 20px;
|
|
1230
|
+
border: none;
|
|
1231
|
+
border-radius: 4px;
|
|
1232
|
+
cursor: pointer;
|
|
1233
|
+
font-size: 16px;
|
|
1234
|
+
|
|
1235
|
+
&:hover {
|
|
1236
|
+
background-color: #0056b3;
|
|
1237
|
+
}
|
|
1238
|
+
\`;
|
|
1239
|
+
|
|
1240
|
+
export function Button(props: HTMLAttributes<HTMLButtonElement>) {
|
|
1241
|
+
return <StyledButton {...props} />;
|
|
1242
|
+
}
|
|
1243
|
+
`;
|
|
1244
|
+
var BUTTON_FILE_GENERATOR = new FileGeneratorImp(
|
|
1245
|
+
"src/button.tsx",
|
|
1246
|
+
BUTTON
|
|
1247
|
+
);
|
|
1248
|
+
|
|
1249
|
+
// src/packages/react-package/styled-components-react-package/files/button-spec-file-generator.ts
|
|
1250
|
+
var BUTTON_SPEC = `import { render, screen, fireEvent } from '@testing-library/react';
|
|
1251
|
+
import { Button } from './button';
|
|
1252
|
+
|
|
1253
|
+
describe('Button', () => {
|
|
876
1254
|
it('renders the label correctly', () => {
|
|
877
1255
|
render(<Button>Click Me</Button>);
|
|
878
1256
|
expect(screen.getByText('Click Me')).toBeDefined();
|
|
@@ -895,13 +1273,13 @@ describe('Button', () => {
|
|
|
895
1273
|
});
|
|
896
1274
|
});
|
|
897
1275
|
`;
|
|
898
|
-
var
|
|
1276
|
+
var BUTTON_SPEC_FILE_GENERATOR = new FileGeneratorImp(
|
|
899
1277
|
"src/button.spec.tsx",
|
|
900
|
-
|
|
1278
|
+
BUTTON_SPEC
|
|
901
1279
|
);
|
|
902
1280
|
|
|
903
1281
|
// src/packages/react-package/styled-components-react-package/files/eslint-config-file-generator.ts
|
|
904
|
-
var
|
|
1282
|
+
var ESLINT_CONFIG4 = `import base from '@stack-dev/eslint-config/base.mjs';
|
|
905
1283
|
import react from '@stack-dev/eslint-config/react.mjs';
|
|
906
1284
|
|
|
907
1285
|
export default [
|
|
@@ -912,31 +1290,31 @@ export default [
|
|
|
912
1290
|
}
|
|
913
1291
|
];
|
|
914
1292
|
`;
|
|
915
|
-
var
|
|
1293
|
+
var ESLINT_CONFIG_FILE_GENERATOR4 = new FileGeneratorImp(
|
|
916
1294
|
"eslint.config.mjs",
|
|
917
|
-
|
|
1295
|
+
ESLINT_CONFIG4
|
|
918
1296
|
);
|
|
919
1297
|
|
|
920
1298
|
// src/packages/react-package/styled-components-react-package/files/index-file-generator.ts
|
|
921
|
-
var
|
|
1299
|
+
var INDEX_TS2 = `export * from './button';
|
|
922
1300
|
`;
|
|
923
|
-
var
|
|
1301
|
+
var INDEX_FILE_GENERATOR4 = new FileGeneratorImp(
|
|
924
1302
|
"src/index.ts",
|
|
925
|
-
|
|
1303
|
+
INDEX_TS2
|
|
926
1304
|
);
|
|
927
1305
|
|
|
928
1306
|
// src/packages/react-package/styled-components-react-package/files/prettier-config-file-generator.ts
|
|
929
|
-
var
|
|
1307
|
+
var PRETTIER_CONFIG4 = `import base from '@stack-dev/prettier-config/base.mjs';
|
|
930
1308
|
|
|
931
1309
|
export default base;
|
|
932
1310
|
`;
|
|
933
|
-
var
|
|
1311
|
+
var PRETTIER_CONFIG_FILE_GENERATOR4 = new FileGeneratorImp(
|
|
934
1312
|
"prettier.config.mjs",
|
|
935
|
-
|
|
1313
|
+
PRETTIER_CONFIG4
|
|
936
1314
|
);
|
|
937
1315
|
|
|
938
1316
|
// src/packages/react-package/styled-components-react-package/files/tsconfig-file-generator.ts
|
|
939
|
-
var
|
|
1317
|
+
var TSCONFIG4 = `{
|
|
940
1318
|
"extends": "@stack-dev/typescript-config/tsconfig.react.json",
|
|
941
1319
|
"compilerOptions": {
|
|
942
1320
|
"outDir": "dist"
|
|
@@ -944,13 +1322,13 @@ var TSCONFIG3 = `{
|
|
|
944
1322
|
"include": ["src"]
|
|
945
1323
|
}
|
|
946
1324
|
`;
|
|
947
|
-
var
|
|
1325
|
+
var TSCONFIG_FILE_GENERATOR4 = new FileGeneratorImp(
|
|
948
1326
|
"tsconfig.json",
|
|
949
|
-
|
|
1327
|
+
TSCONFIG4
|
|
950
1328
|
);
|
|
951
1329
|
|
|
952
1330
|
// src/packages/react-package/styled-components-react-package/files/tsup-config-file-generator.ts
|
|
953
|
-
var
|
|
1331
|
+
var TSUP_CONFIG2 = `import { defineConfig } from 'tsup';
|
|
954
1332
|
|
|
955
1333
|
export default defineConfig({
|
|
956
1334
|
entry: ['src/index.ts'],
|
|
@@ -964,13 +1342,13 @@ export default defineConfig({
|
|
|
964
1342
|
};
|
|
965
1343
|
},
|
|
966
1344
|
});`;
|
|
967
|
-
var
|
|
1345
|
+
var TSUP_CONFIG_FILE_GENERATOR2 = new FileGeneratorImp(
|
|
968
1346
|
"tsup.config.ts",
|
|
969
|
-
|
|
1347
|
+
TSUP_CONFIG2
|
|
970
1348
|
);
|
|
971
1349
|
|
|
972
1350
|
// src/packages/react-package/styled-components-react-package/files/vitest-config-file-generator.ts
|
|
973
|
-
var
|
|
1351
|
+
var VITEST_CONFIG4 = `import { defineConfig } from 'vitest/config';
|
|
974
1352
|
import react from '@vitejs/plugin-react';
|
|
975
1353
|
|
|
976
1354
|
export default defineConfig({
|
|
@@ -986,38 +1364,36 @@ export default defineConfig({
|
|
|
986
1364
|
},
|
|
987
1365
|
});
|
|
988
1366
|
`;
|
|
989
|
-
var
|
|
1367
|
+
var VITEST_CONFIG_FILE_GENERATOR4 = new FileGeneratorImp(
|
|
990
1368
|
"vitest.config.ts",
|
|
991
|
-
|
|
1369
|
+
VITEST_CONFIG4
|
|
992
1370
|
);
|
|
993
1371
|
|
|
994
1372
|
// src/packages/react-package/styled-components-react-package/create-styled-components-react-package.ts
|
|
995
1373
|
async function createStyledComponentsReactPackage(name) {
|
|
996
1374
|
const rootDir = await getWorkspaceRoot();
|
|
997
|
-
const directory =
|
|
1375
|
+
const directory = import_path4.default.join(rootDir, "packages", name);
|
|
998
1376
|
const namespace = await getNamespace(rootDir);
|
|
999
1377
|
const packageName = `${namespace}/${name}`;
|
|
1000
|
-
console.log(
|
|
1001
|
-
`\u2728 Creating Styled Components Modules React library: ${packageName}`
|
|
1002
|
-
);
|
|
1378
|
+
console.log(`\u2728 Creating Styled Components React library: ${packageName}`);
|
|
1003
1379
|
const generator = new PackageGenerator(
|
|
1004
1380
|
directory,
|
|
1005
|
-
|
|
1381
|
+
makePackageGenerator2(packageName, namespace),
|
|
1006
1382
|
[
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1383
|
+
INDEX_FILE_GENERATOR4,
|
|
1384
|
+
BUTTON_FILE_GENERATOR,
|
|
1385
|
+
BUTTON_SPEC_FILE_GENERATOR,
|
|
1386
|
+
TSUP_CONFIG_FILE_GENERATOR2,
|
|
1387
|
+
TSCONFIG_FILE_GENERATOR4,
|
|
1388
|
+
PRETTIER_CONFIG_FILE_GENERATOR4,
|
|
1389
|
+
ESLINT_CONFIG_FILE_GENERATOR4,
|
|
1390
|
+
VITEST_CONFIG_FILE_GENERATOR4
|
|
1015
1391
|
]
|
|
1016
1392
|
);
|
|
1017
1393
|
await generator.generate();
|
|
1018
1394
|
console.log(`\u2705 Library created at: ${directory}`);
|
|
1019
1395
|
}
|
|
1020
|
-
function
|
|
1396
|
+
function makePackageGenerator2(packageName, namespace) {
|
|
1021
1397
|
const packageJsonModel = new PackageJSON({
|
|
1022
1398
|
name: packageName,
|
|
1023
1399
|
// Peer deps are crucial for Styled Components to prevent "Multiple instances" errors
|
|
@@ -1084,420 +1460,235 @@ function makePackageGenerator3(packageName, namespace) {
|
|
|
1084
1460
|
return new PackageJsonGenerator(packageJsonModel, namespace);
|
|
1085
1461
|
}
|
|
1086
1462
|
|
|
1087
|
-
// src/packages/react-package/create-react-package.ts
|
|
1088
|
-
|
|
1089
|
-
switch (style) {
|
|
1090
|
-
case "tailwind":
|
|
1091
|
-
await createTailwindReactPackage(name);
|
|
1092
|
-
break;
|
|
1093
|
-
case "css-modules":
|
|
1094
|
-
await createCssReactPackage(name);
|
|
1095
|
-
break;
|
|
1096
|
-
case "styled-components":
|
|
1097
|
-
await createStyledComponentsReactPackage(name);
|
|
1098
|
-
break;
|
|
1099
|
-
case "none":
|
|
1100
|
-
await createUnstyledReactPackage(name);
|
|
1101
|
-
break;
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1463
|
+
// src/packages/react-package/unstyled-react-package/create-unstyled-react-package.ts
|
|
1464
|
+
var import_path5 = __toESM(require("path"));
|
|
1104
1465
|
|
|
1105
|
-
// src/packages/
|
|
1106
|
-
var
|
|
1107
|
-
async function createConfigPackage(name) {
|
|
1108
|
-
const rootDir = await getWorkspaceRoot();
|
|
1109
|
-
const directory = import_node_path4.default.join(rootDir, "configs", name);
|
|
1110
|
-
const namespace = await getNamespace(rootDir);
|
|
1111
|
-
const packageName = `${namespace}/${name}`;
|
|
1112
|
-
const packageJsonModel = new PackageJSON({
|
|
1113
|
-
name: packageName,
|
|
1114
|
-
additionalData: {
|
|
1115
|
-
version: "0.1.0",
|
|
1116
|
-
private: true
|
|
1117
|
-
}
|
|
1118
|
-
});
|
|
1119
|
-
const generator = new PackageGenerator(
|
|
1120
|
-
directory,
|
|
1121
|
-
new PackageJsonGenerator(packageJsonModel, namespace),
|
|
1122
|
-
[]
|
|
1123
|
-
);
|
|
1124
|
-
await generator.generate();
|
|
1125
|
-
}
|
|
1466
|
+
// src/packages/react-package/unstyled-react-package/files/button-file-generator.ts
|
|
1467
|
+
var BUTTON2 = `import React, { HTMLAttributes } from 'react';
|
|
1126
1468
|
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
var import_node_path5 = __toESM(require("path"));
|
|
1130
|
-
async function getCurrentPackage(directory = process.cwd()) {
|
|
1131
|
-
const packageRoot = await getPackageRoot(directory);
|
|
1132
|
-
const packageJson = await getDirectoryPackageJson(packageRoot);
|
|
1133
|
-
return getPackageByName(packageJson.name);
|
|
1134
|
-
}
|
|
1135
|
-
async function getPackageRoot(directory = process.cwd()) {
|
|
1136
|
-
const parent = import_node_path5.default.dirname(directory);
|
|
1137
|
-
if (parent === directory) {
|
|
1138
|
-
throw new Error("Not a package.");
|
|
1139
|
-
}
|
|
1140
|
-
if (await isPackageRoot(directory)) {
|
|
1141
|
-
return directory;
|
|
1142
|
-
}
|
|
1143
|
-
return getPackageRoot(parent);
|
|
1144
|
-
}
|
|
1145
|
-
async function getPackageByName(name) {
|
|
1146
|
-
const all = await getAllPackages();
|
|
1147
|
-
const match = all.find((p) => p.name === name);
|
|
1148
|
-
if (match === void 0) {
|
|
1149
|
-
throw new Error(`No package with name "${name}".`);
|
|
1150
|
-
}
|
|
1151
|
-
return match;
|
|
1152
|
-
}
|
|
1153
|
-
async function getAllPackages(directory = process.cwd()) {
|
|
1154
|
-
const workspaceRoot = await getWorkspaceRoot(directory);
|
|
1155
|
-
const workspaceFile = await getDirectoryWorkspaceFile(workspaceRoot);
|
|
1156
|
-
const results = [];
|
|
1157
|
-
for (const seg of workspaceFile.packages) {
|
|
1158
|
-
const packageType = getPackageType(seg);
|
|
1159
|
-
const packageJsonPaths = await (0, import_fast_glob.glob)(`${workspaceRoot}/${seg}/package.json`);
|
|
1160
|
-
const packageDirectories = packageJsonPaths.map((p) => import_node_path5.default.dirname(p));
|
|
1161
|
-
for (const directory2 of packageDirectories) {
|
|
1162
|
-
const name = (await getDirectoryPackageJson(directory2)).name;
|
|
1163
|
-
results.push({
|
|
1164
|
-
name,
|
|
1165
|
-
directory: directory2,
|
|
1166
|
-
type: packageType
|
|
1167
|
-
});
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
return results;
|
|
1171
|
-
}
|
|
1172
|
-
function getPackageType(segment) {
|
|
1173
|
-
if (segment.startsWith("app")) {
|
|
1174
|
-
return "App";
|
|
1175
|
-
} else if (segment.startsWith("config")) {
|
|
1176
|
-
return "Config";
|
|
1177
|
-
} else if (segment.startsWith("package") || segment.startsWith("lib")) {
|
|
1178
|
-
return "Library";
|
|
1179
|
-
} else {
|
|
1180
|
-
return "Unknown";
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
function comparePackages(a, b) {
|
|
1184
|
-
const packageTypeDifference = comparePackageTypes(a.type, b.type);
|
|
1185
|
-
if (packageTypeDifference !== 0) {
|
|
1186
|
-
return packageTypeDifference;
|
|
1187
|
-
} else {
|
|
1188
|
-
return a.name.localeCompare(b.name);
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
function comparePackageTypes(a, b) {
|
|
1192
|
-
return getPackageTypeIndex(a) - getPackageTypeIndex(b);
|
|
1193
|
-
}
|
|
1194
|
-
function getPackageTypeIndex(packageType) {
|
|
1195
|
-
switch (packageType) {
|
|
1196
|
-
case "Library":
|
|
1197
|
-
return 0;
|
|
1198
|
-
case "Config":
|
|
1199
|
-
return 1;
|
|
1200
|
-
case "App":
|
|
1201
|
-
return 2;
|
|
1202
|
-
case "Unknown":
|
|
1203
|
-
return 3;
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
async function isPackageRoot(directory) {
|
|
1207
|
-
return await fileExists(import_node_path5.default.join(directory, "package.json"));
|
|
1469
|
+
export function Button(props: HTMLAttributes<HTMLButtonElement>) {
|
|
1470
|
+
return <button {...props} />;
|
|
1208
1471
|
}
|
|
1472
|
+
`;
|
|
1473
|
+
var BUTTON_FILE_GENERATOR2 = new FileGeneratorImp(
|
|
1474
|
+
"src/button.tsx",
|
|
1475
|
+
BUTTON2
|
|
1476
|
+
);
|
|
1209
1477
|
|
|
1210
|
-
// src/
|
|
1211
|
-
var
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
"next",
|
|
1219
|
-
"cli"
|
|
1220
|
-
];
|
|
1221
|
-
async function pickPackageType(options) {
|
|
1222
|
-
if (options?.type && isPackageType(options.type)) {
|
|
1223
|
-
return options.type;
|
|
1224
|
-
} else if (options?.type && !isPackageType(options.type)) {
|
|
1225
|
-
throw new Error(
|
|
1226
|
-
`--type setting "${options.type}" is invalid, must be one of ${packageTypes.join(", ")}.`
|
|
1227
|
-
);
|
|
1228
|
-
}
|
|
1229
|
-
const response = await (0, import_enquirer.prompt)({
|
|
1230
|
-
type: "select",
|
|
1231
|
-
name: "type",
|
|
1232
|
-
message: "What kind of package do you want?",
|
|
1233
|
-
choices: [...packageTypes]
|
|
1478
|
+
// src/packages/react-package/unstyled-react-package/files/button-spec-file-generator.ts
|
|
1479
|
+
var BUTTON_SPEC2 = `import { render, screen, fireEvent } from '@testing-library/react';
|
|
1480
|
+
import { Button } from './button';
|
|
1481
|
+
|
|
1482
|
+
describe('Button', () => {
|
|
1483
|
+
it('renders the label correctly', () => {
|
|
1484
|
+
render(<Button>Click Me</Button>);
|
|
1485
|
+
expect(screen.getByText('Click Me')).toBeDefined();
|
|
1234
1486
|
});
|
|
1235
|
-
if (!isPackageType(response.type)) {
|
|
1236
|
-
throw new Error(
|
|
1237
|
-
`Type "${response.type}" is invalid, must be one of ${packageTypes.join(", ")}.`
|
|
1238
|
-
);
|
|
1239
|
-
}
|
|
1240
|
-
return response.type;
|
|
1241
|
-
}
|
|
1242
|
-
function isPackageType(s) {
|
|
1243
|
-
return packageTypes.some((p) => p === s);
|
|
1244
|
-
}
|
|
1245
1487
|
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
"css-modules",
|
|
1251
|
-
"styled-components",
|
|
1252
|
-
"none"
|
|
1253
|
-
];
|
|
1254
|
-
async function pickStyleType(options) {
|
|
1255
|
-
if (options?.style && isStyleType(options?.style)) {
|
|
1256
|
-
return options?.style;
|
|
1257
|
-
} else if (options?.style && !isStyleType(options?.style)) {
|
|
1258
|
-
throw new Error(
|
|
1259
|
-
`--style setting "${options.style}" is invalid, must be one of ${styleTypes.join(", ")}.`
|
|
1260
|
-
);
|
|
1261
|
-
}
|
|
1262
|
-
const response = await (0, import_enquirer2.prompt)({
|
|
1263
|
-
type: "select",
|
|
1264
|
-
name: "type",
|
|
1265
|
-
message: "What kind of style do you want?",
|
|
1266
|
-
choices: [...styleTypes]
|
|
1488
|
+
it('is a button element', () => {
|
|
1489
|
+
render(<Button>Submit</Button>);
|
|
1490
|
+
const buttonElement = screen.getByRole('button');
|
|
1491
|
+
expect(buttonElement.tagName).toBe('BUTTON');
|
|
1267
1492
|
});
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
}
|
|
1275
|
-
function isStyleType(s) {
|
|
1276
|
-
return styleTypes.some((p) => p === s);
|
|
1277
|
-
}
|
|
1493
|
+
});
|
|
1494
|
+
`;
|
|
1495
|
+
var BUTTON_SPEC_FILE_GENERATOR2 = new FileGeneratorImp(
|
|
1496
|
+
"src/button.spec.tsx",
|
|
1497
|
+
BUTTON_SPEC2
|
|
1498
|
+
);
|
|
1278
1499
|
|
|
1279
|
-
// src/
|
|
1280
|
-
var
|
|
1281
|
-
|
|
1500
|
+
// src/packages/react-package/unstyled-react-package/files/eslint-config-file-generator.ts
|
|
1501
|
+
var ESLINT_CONFIG5 = `import base from '@stack-dev/eslint-config/base.mjs';
|
|
1502
|
+
import react from '@stack-dev/eslint-config/react.mjs';
|
|
1282
1503
|
|
|
1283
|
-
|
|
1284
|
-
|
|
1504
|
+
export default [
|
|
1505
|
+
...base,
|
|
1506
|
+
...react,
|
|
1507
|
+
{
|
|
1508
|
+
ignores: ['**/dist/**', '**/coverage/**']
|
|
1509
|
+
}
|
|
1510
|
+
];
|
|
1511
|
+
`;
|
|
1512
|
+
var ESLINT_CONFIG_FILE_GENERATOR5 = new FileGeneratorImp(
|
|
1513
|
+
"eslint.config.mjs",
|
|
1514
|
+
ESLINT_CONFIG5
|
|
1515
|
+
);
|
|
1285
1516
|
|
|
1286
|
-
// src/
|
|
1287
|
-
var
|
|
1288
|
-
|
|
1517
|
+
// src/packages/react-package/unstyled-react-package/files/index-file-generator.ts
|
|
1518
|
+
var INDEX_TS3 = `export * from './button';
|
|
1519
|
+
`;
|
|
1520
|
+
var INDEX_FILE_GENERATOR5 = new FileGeneratorImp(
|
|
1521
|
+
"src/index.ts",
|
|
1522
|
+
INDEX_TS3
|
|
1523
|
+
);
|
|
1289
1524
|
|
|
1290
|
-
// src/
|
|
1291
|
-
var
|
|
1292
|
-
var import_core3 = require("@stack-dev/core");
|
|
1293
|
-
var import_lodash3 = require("lodash");
|
|
1525
|
+
// src/packages/react-package/unstyled-react-package/files/prettier-config-file-generator.ts
|
|
1526
|
+
var PRETTIER_CONFIG5 = `import base from '@stack-dev/prettier-config/base.mjs';
|
|
1294
1527
|
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
var
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
return this._additionalData;
|
|
1310
|
-
}
|
|
1311
|
-
setPaths(paths) {
|
|
1312
|
-
return new _CompilerOptions({
|
|
1313
|
-
paths,
|
|
1314
|
-
additionalData: this._additionalData
|
|
1315
|
-
});
|
|
1316
|
-
}
|
|
1317
|
-
format() {
|
|
1318
|
-
const json = {
|
|
1319
|
-
paths: this._paths,
|
|
1320
|
-
...this._additionalData
|
|
1321
|
-
};
|
|
1322
|
-
const ordered = (0, import_core2.sortKeys)(json, compareKeys);
|
|
1323
|
-
return JSON.stringify(ordered, null, 2);
|
|
1324
|
-
}
|
|
1325
|
-
equals(other) {
|
|
1326
|
-
if (other instanceof _CompilerOptions) {
|
|
1327
|
-
return (0, import_lodash2.isEqual)(this._paths, other._paths) && (0, import_lodash2.isEqual)(this._additionalData, other._additionalData);
|
|
1328
|
-
} else {
|
|
1329
|
-
return false;
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1332
|
-
};
|
|
1333
|
-
function compareKeys(a, b) {
|
|
1334
|
-
return getKeyIndex2(a) - getKeyIndex2(b);
|
|
1335
|
-
}
|
|
1336
|
-
function getKeyIndex2(s) {
|
|
1337
|
-
const order = [
|
|
1338
|
-
"target",
|
|
1339
|
-
"module",
|
|
1340
|
-
"moduleResolution",
|
|
1341
|
-
"esModuleInterop",
|
|
1342
|
-
"lib",
|
|
1343
|
-
"types",
|
|
1344
|
-
"strict",
|
|
1345
|
-
"allowJs"
|
|
1346
|
-
];
|
|
1347
|
-
if (order.every((key) => key !== s)) {
|
|
1348
|
-
return Number.MAX_VALUE;
|
|
1349
|
-
} else {
|
|
1350
|
-
return order.indexOf(s);
|
|
1351
|
-
}
|
|
1528
|
+
export default base;
|
|
1529
|
+
`;
|
|
1530
|
+
var PRETTIER_CONFIG_FILE_GENERATOR5 = new FileGeneratorImp(
|
|
1531
|
+
"prettier.config.mjs",
|
|
1532
|
+
PRETTIER_CONFIG5
|
|
1533
|
+
);
|
|
1534
|
+
|
|
1535
|
+
// src/packages/react-package/unstyled-react-package/files/tsconfig-file-generator.ts
|
|
1536
|
+
var TSCONFIG5 = `{
|
|
1537
|
+
"extends": "@stack-dev/typescript-config/tsconfig.react.json",
|
|
1538
|
+
"compilerOptions": {
|
|
1539
|
+
"outDir": "dist"
|
|
1540
|
+
},
|
|
1541
|
+
"include": ["src"]
|
|
1352
1542
|
}
|
|
1543
|
+
`;
|
|
1544
|
+
var TSCONFIG_FILE_GENERATOR5 = new FileGeneratorImp(
|
|
1545
|
+
"tsconfig.json",
|
|
1546
|
+
TSCONFIG5
|
|
1547
|
+
);
|
|
1353
1548
|
|
|
1354
|
-
// src/
|
|
1355
|
-
var
|
|
1356
|
-
_path;
|
|
1357
|
-
constructor(path14) {
|
|
1358
|
-
this._path = path14;
|
|
1359
|
-
}
|
|
1360
|
-
get path() {
|
|
1361
|
-
return this._path;
|
|
1362
|
-
}
|
|
1363
|
-
equals(other) {
|
|
1364
|
-
if (other instanceof _Reference) {
|
|
1365
|
-
return this._path === other._path;
|
|
1366
|
-
} else {
|
|
1367
|
-
return false;
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
};
|
|
1549
|
+
// src/packages/react-package/unstyled-react-package/files/tsup-config-file-generator.ts
|
|
1550
|
+
var TSUP_CONFIG3 = `import { defineConfig } from 'tsup';
|
|
1371
1551
|
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
}
|
|
1382
|
-
get compilerOptions() {
|
|
1383
|
-
return this._compilerOptions;
|
|
1384
|
-
}
|
|
1385
|
-
addReference(reference) {
|
|
1386
|
-
return new _TSConfig({
|
|
1387
|
-
compilerOptions: this._compilerOptions,
|
|
1388
|
-
references: [...this._references, reference],
|
|
1389
|
-
additionalData: this._additionalData
|
|
1390
|
-
});
|
|
1391
|
-
}
|
|
1392
|
-
setCompilerOptions(compilerOptions) {
|
|
1393
|
-
return new _TSConfig({
|
|
1394
|
-
compilerOptions,
|
|
1395
|
-
references: this._references,
|
|
1396
|
-
additionalData: this._additionalData
|
|
1397
|
-
});
|
|
1398
|
-
}
|
|
1399
|
-
static parse(s) {
|
|
1400
|
-
const json = JSON52.parse(s);
|
|
1401
|
-
const references = _TSConfig.parseReferences(json);
|
|
1402
|
-
const compilerOptions = new CompilerOptions({
|
|
1403
|
-
paths: json.compilerOptions?.paths,
|
|
1404
|
-
...json.compilerOptions
|
|
1405
|
-
});
|
|
1406
|
-
const additionalData = { ...json };
|
|
1407
|
-
delete additionalData["compilerOptions"];
|
|
1408
|
-
delete additionalData["references"];
|
|
1409
|
-
return new _TSConfig({
|
|
1410
|
-
compilerOptions,
|
|
1411
|
-
references,
|
|
1412
|
-
additionalData
|
|
1413
|
-
});
|
|
1414
|
-
}
|
|
1415
|
-
static parseReferences(json) {
|
|
1416
|
-
if (typeof json === "object" && json !== null && "references" in json && json.references instanceof Array) {
|
|
1417
|
-
return json.references.map(
|
|
1418
|
-
(r) => new Reference(r.path)
|
|
1419
|
-
);
|
|
1420
|
-
} else {
|
|
1421
|
-
return [];
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
format() {
|
|
1425
|
-
const compilerOptions = JSON52.parse(this.compilerOptions.format());
|
|
1426
|
-
const json = {
|
|
1427
|
-
compilerOptions,
|
|
1428
|
-
references: this._references.map((r) => ({ path: r.path })),
|
|
1429
|
-
...this._additionalData
|
|
1552
|
+
export default defineConfig({
|
|
1553
|
+
entry: ['src/index.ts'],
|
|
1554
|
+
format: ['esm', 'cjs'],
|
|
1555
|
+
dts: true,
|
|
1556
|
+
clean: true,
|
|
1557
|
+
external: ['react', 'react-dom', 'styled-components'],
|
|
1558
|
+
outExtension({ format }) {
|
|
1559
|
+
return {
|
|
1560
|
+
js: format === 'esm' ? '.mjs' : '.js',
|
|
1430
1561
|
};
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1562
|
+
},
|
|
1563
|
+
});`;
|
|
1564
|
+
var TSUP_CONFIG_FILE_GENERATOR3 = new FileGeneratorImp(
|
|
1565
|
+
"tsup.config.ts",
|
|
1566
|
+
TSUP_CONFIG3
|
|
1567
|
+
);
|
|
1568
|
+
|
|
1569
|
+
// src/packages/react-package/unstyled-react-package/files/vitest-config-file-generator.ts
|
|
1570
|
+
var VITEST_CONFIG5 = `import { defineConfig } from 'vitest/config';
|
|
1571
|
+
import react from '@vitejs/plugin-react';
|
|
1572
|
+
|
|
1573
|
+
export default defineConfig({
|
|
1574
|
+
plugins: [react()],
|
|
1575
|
+
test: {
|
|
1576
|
+
globals: true,
|
|
1577
|
+
environment: 'jsdom',
|
|
1578
|
+
coverage: {
|
|
1579
|
+
provider: 'v8',
|
|
1580
|
+
reporter: ['text', 'json', 'html'],
|
|
1581
|
+
},
|
|
1582
|
+
css: true,
|
|
1583
|
+
},
|
|
1584
|
+
});
|
|
1585
|
+
`;
|
|
1586
|
+
var VITEST_CONFIG_FILE_GENERATOR5 = new FileGeneratorImp(
|
|
1587
|
+
"vitest.config.ts",
|
|
1588
|
+
VITEST_CONFIG5
|
|
1589
|
+
);
|
|
1590
|
+
|
|
1591
|
+
// src/packages/react-package/unstyled-react-package/create-unstyled-react-package.ts
|
|
1592
|
+
async function createUnstyledReactPackage(name) {
|
|
1593
|
+
const rootDir = await getWorkspaceRoot();
|
|
1594
|
+
const directory = import_path5.default.join(rootDir, "packages", name);
|
|
1595
|
+
const namespace = await getNamespace(rootDir);
|
|
1596
|
+
const packageName = `${namespace}/${name}`;
|
|
1597
|
+
console.log(`\u2728 Creating Un-styled React library: ${packageName}`);
|
|
1598
|
+
const generator = new PackageGenerator(
|
|
1599
|
+
directory,
|
|
1600
|
+
makePackageGenerator3(packageName, namespace),
|
|
1601
|
+
[
|
|
1602
|
+
INDEX_FILE_GENERATOR5,
|
|
1603
|
+
BUTTON_FILE_GENERATOR2,
|
|
1604
|
+
BUTTON_SPEC_FILE_GENERATOR2,
|
|
1605
|
+
TSUP_CONFIG_FILE_GENERATOR3,
|
|
1606
|
+
TSCONFIG_FILE_GENERATOR5,
|
|
1607
|
+
PRETTIER_CONFIG_FILE_GENERATOR5,
|
|
1608
|
+
ESLINT_CONFIG_FILE_GENERATOR5,
|
|
1609
|
+
VITEST_CONFIG_FILE_GENERATOR5
|
|
1610
|
+
]
|
|
1611
|
+
);
|
|
1612
|
+
await generator.generate();
|
|
1613
|
+
console.log(`\u2705 Library created at: ${directory}`);
|
|
1614
|
+
}
|
|
1615
|
+
function makePackageGenerator3(packageName, namespace) {
|
|
1616
|
+
const packageJsonModel = new PackageJSON({
|
|
1617
|
+
name: packageName,
|
|
1618
|
+
// Peer deps are crucial for Styled Components to prevent "Multiple instances" errors
|
|
1619
|
+
peerDependencies: [
|
|
1620
|
+
new Dependency("react", ">=18"),
|
|
1621
|
+
new Dependency("react-dom", ">=18")
|
|
1622
|
+
],
|
|
1623
|
+
devDependencies: [
|
|
1624
|
+
new Dependency(`${namespace}/eslint-config`, "workspace:*"),
|
|
1625
|
+
new Dependency(`${namespace}/prettier-config`, "workspace:*"),
|
|
1626
|
+
new Dependency(`${namespace}/typescript-config`, "workspace:*"),
|
|
1627
|
+
// Development React binaries
|
|
1628
|
+
new Dependency("react", "^18.3.1"),
|
|
1629
|
+
new Dependency("react-dom", "^18.3.1"),
|
|
1630
|
+
new Dependency("@types/react", "^18.3.1"),
|
|
1631
|
+
new Dependency("@types/react-dom", "^18.3.1"),
|
|
1632
|
+
// Linting & Formatting
|
|
1633
|
+
new Dependency("eslint", "^9.32.0"),
|
|
1634
|
+
new Dependency("prettier", "^3.6.2"),
|
|
1635
|
+
new Dependency("prettier-plugin-organize-imports", "^4.2.0"),
|
|
1636
|
+
// Build
|
|
1637
|
+
new Dependency("tsup", "^8.0.0"),
|
|
1638
|
+
// Testing
|
|
1639
|
+
new Dependency("vitest", "^3.2.4"),
|
|
1640
|
+
new Dependency("@vitest/coverage-v8", "^3.2.4"),
|
|
1641
|
+
new Dependency("@testing-library/react", "^16.0.0"),
|
|
1642
|
+
new Dependency("@testing-library/jest-dom", "^6.0.0"),
|
|
1643
|
+
new Dependency("jsdom", "^25.0.0")
|
|
1644
|
+
],
|
|
1645
|
+
additionalData: {
|
|
1646
|
+
version: "0.1.0",
|
|
1647
|
+
private: true,
|
|
1648
|
+
type: "module",
|
|
1649
|
+
// Added this to ensure ESM consistency
|
|
1650
|
+
main: "dist/index.js",
|
|
1651
|
+
module: "dist/index.mjs",
|
|
1652
|
+
types: "dist/index.d.ts",
|
|
1653
|
+
exports: {
|
|
1654
|
+
".": {
|
|
1655
|
+
development: "./src/index.ts",
|
|
1656
|
+
import: "./dist/index.mjs",
|
|
1657
|
+
require: "./dist/index.js",
|
|
1658
|
+
types: "./dist/index.d.ts"
|
|
1659
|
+
}
|
|
1660
|
+
// Removed './index.css' as it's no longer produced by Styled Components
|
|
1661
|
+
},
|
|
1662
|
+
scripts: {
|
|
1663
|
+
build: "tsup",
|
|
1664
|
+
dev: "tsup --watch",
|
|
1665
|
+
// Helpful for local lib dev
|
|
1666
|
+
lint: "eslint .",
|
|
1667
|
+
format: "prettier . --write",
|
|
1668
|
+
test: "vitest run",
|
|
1669
|
+
"test:watch": "vitest"
|
|
1670
|
+
},
|
|
1671
|
+
// Set to false or removed because Styled Components are pure JS/TS
|
|
1672
|
+
sideEffects: false
|
|
1444
1673
|
}
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
|
-
function compareKeys2(a, b) {
|
|
1448
|
-
return getKeyIndex3(a) - getKeyIndex3(b);
|
|
1449
|
-
}
|
|
1450
|
-
function getKeyIndex3(s) {
|
|
1451
|
-
const order = [
|
|
1452
|
-
"extends",
|
|
1453
|
-
"compilerOptions",
|
|
1454
|
-
"include",
|
|
1455
|
-
"exclude",
|
|
1456
|
-
"references"
|
|
1457
|
-
];
|
|
1458
|
-
if (order.every((key) => key !== s)) {
|
|
1459
|
-
return Number.MAX_VALUE;
|
|
1460
|
-
} else {
|
|
1461
|
-
return order.indexOf(s);
|
|
1462
|
-
}
|
|
1674
|
+
});
|
|
1675
|
+
return new PackageJsonGenerator(packageJsonModel, namespace);
|
|
1463
1676
|
}
|
|
1464
1677
|
|
|
1465
|
-
// src/
|
|
1466
|
-
async function
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
const packageJSONPath = getPackageJSONPath(current.directory);
|
|
1475
|
-
await import_promises4.default.writeFile(packageJSONPath, updated.format(namespace));
|
|
1476
|
-
}
|
|
1477
|
-
function addDependency(packageJSON, target, development) {
|
|
1478
|
-
const dependency = new Dependency(target.name, "workspace:*");
|
|
1479
|
-
if (development) {
|
|
1480
|
-
return packageJSON.addDevDependency(dependency);
|
|
1481
|
-
} else {
|
|
1482
|
-
return packageJSON.addDependency(dependency);
|
|
1678
|
+
// src/packages/react-package/create-react-package.ts
|
|
1679
|
+
async function createReactPackage(name, style) {
|
|
1680
|
+
switch (style) {
|
|
1681
|
+
case "styled-components":
|
|
1682
|
+
await createStyledComponentsReactPackage(name);
|
|
1683
|
+
break;
|
|
1684
|
+
case "none":
|
|
1685
|
+
await createUnstyledReactPackage(name);
|
|
1686
|
+
break;
|
|
1483
1687
|
}
|
|
1484
1688
|
}
|
|
1485
|
-
async function updateTSConfig(current, target) {
|
|
1486
|
-
const tsconfigPath = import_node_path6.default.join(current.directory, "tsconfig.json");
|
|
1487
|
-
const tsconfigContents = await import_promises4.default.readFile(tsconfigPath, "utf8");
|
|
1488
|
-
const tsconfig = TSConfig.parse(tsconfigContents);
|
|
1489
|
-
const targetDirectory = import_node_path6.default.join(target.directory, "src", "index.ts");
|
|
1490
|
-
const updatedPaths = {
|
|
1491
|
-
...tsconfig.compilerOptions.paths,
|
|
1492
|
-
[target.name]: [import_node_path6.default.relative(current.directory, targetDirectory)]
|
|
1493
|
-
};
|
|
1494
|
-
const updatedCompilerOptions = tsconfig.compilerOptions.setPaths(updatedPaths);
|
|
1495
|
-
const updated = tsconfig.setCompilerOptions(updatedCompilerOptions);
|
|
1496
|
-
await import_promises4.default.writeFile(tsconfigPath, updated.format());
|
|
1497
|
-
}
|
|
1498
1689
|
|
|
1499
1690
|
// src/packages/vite-react-app/create-vite-react-app.ts
|
|
1500
|
-
var
|
|
1691
|
+
var import_path6 = __toESM(require("path"));
|
|
1501
1692
|
|
|
1502
1693
|
// src/packages/vite-react-app/files/index-html-file-generator.ts
|
|
1503
1694
|
var INDEX_HTML = `<!doctype html>
|
|
@@ -1575,27 +1766,27 @@ export function App() {
|
|
|
1575
1766
|
var APP_FILE_GENERATOR = new FileGeneratorImp("src/App.tsx", APP);
|
|
1576
1767
|
|
|
1577
1768
|
// src/packages/vite-react-app/files/eslint-config-file-generator.ts
|
|
1578
|
-
var
|
|
1769
|
+
var ESLINT_CONFIG6 = `import base from '@stack-dev/eslint-config/base.mjs';
|
|
1579
1770
|
|
|
1580
1771
|
export default [...base, { ignores: ['**/dist/**'] }];
|
|
1581
1772
|
`;
|
|
1582
|
-
var
|
|
1773
|
+
var ESLINT_CONFIG_FILE_GENERATOR6 = new FileGeneratorImp(
|
|
1583
1774
|
"eslint.config.mjs",
|
|
1584
|
-
|
|
1775
|
+
ESLINT_CONFIG6
|
|
1585
1776
|
);
|
|
1586
1777
|
|
|
1587
1778
|
// src/packages/vite-react-app/files/prettier-config-file-generator.ts
|
|
1588
|
-
var
|
|
1779
|
+
var PRETTIER_CONFIG6 = `import base from '@stack-dev/prettier-config/base.mjs';
|
|
1589
1780
|
|
|
1590
1781
|
export default base;
|
|
1591
1782
|
`;
|
|
1592
|
-
var
|
|
1783
|
+
var PRETTIER_CONFIG_FILE_GENERATOR6 = new FileGeneratorImp(
|
|
1593
1784
|
"prettier.config.mjs",
|
|
1594
|
-
|
|
1785
|
+
PRETTIER_CONFIG6
|
|
1595
1786
|
);
|
|
1596
1787
|
|
|
1597
1788
|
// src/packages/vite-react-app/files/tsconfig-file-generator.ts
|
|
1598
|
-
var
|
|
1789
|
+
var TSCONFIG6 = `{
|
|
1599
1790
|
"extends": "@stack-dev/typescript-config/tsconfig.react.json",
|
|
1600
1791
|
"compilerOptions": {
|
|
1601
1792
|
"outDir": "dist"
|
|
@@ -1603,13 +1794,13 @@ var TSCONFIG4 = `{
|
|
|
1603
1794
|
"include": ["src"]
|
|
1604
1795
|
}
|
|
1605
1796
|
`;
|
|
1606
|
-
var
|
|
1797
|
+
var TSCONFIG_FILE_GENERATOR6 = new FileGeneratorImp(
|
|
1607
1798
|
"tsconfig.json",
|
|
1608
|
-
|
|
1799
|
+
TSCONFIG6
|
|
1609
1800
|
);
|
|
1610
1801
|
|
|
1611
1802
|
// src/packages/vite-react-app/files/vitest-config-file-generator.ts
|
|
1612
|
-
var
|
|
1803
|
+
var VITEST_CONFIG6 = `import { defineConfig } from 'vitest/config';
|
|
1613
1804
|
|
|
1614
1805
|
export default defineConfig({
|
|
1615
1806
|
test: {
|
|
@@ -1621,35 +1812,35 @@ export default defineConfig({
|
|
|
1621
1812
|
},
|
|
1622
1813
|
});
|
|
1623
1814
|
`;
|
|
1624
|
-
var
|
|
1815
|
+
var VITEST_CONFIG_FILE_GENERATOR6 = new FileGeneratorImp(
|
|
1625
1816
|
"vitest.config.ts",
|
|
1626
|
-
|
|
1817
|
+
VITEST_CONFIG6
|
|
1627
1818
|
);
|
|
1628
1819
|
|
|
1629
1820
|
// src/packages/vite-react-app/create-vite-react-app.ts
|
|
1630
1821
|
async function createViteReactApp(name) {
|
|
1631
1822
|
const rootDir = await getWorkspaceRoot();
|
|
1632
|
-
const directory =
|
|
1823
|
+
const directory = import_path6.default.join(rootDir, "apps", name);
|
|
1633
1824
|
const namespace = await getNamespace(rootDir);
|
|
1634
1825
|
const packageName = `${namespace}/${name}`;
|
|
1635
1826
|
console.log(`\u{1F680} Creating Vite React App: ${packageName}`);
|
|
1636
1827
|
const generator = new PackageGenerator(
|
|
1637
1828
|
directory,
|
|
1638
|
-
|
|
1829
|
+
makeAppPackageGenerator3(packageName, namespace),
|
|
1639
1830
|
[
|
|
1640
1831
|
VITE_CONFIG_FILE_GENERATOR,
|
|
1641
1832
|
INDEX_HTML_FILE_GENERATOR,
|
|
1642
1833
|
MAIN_FILE_GENERATOR,
|
|
1643
1834
|
APP_FILE_GENERATOR,
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1835
|
+
TSCONFIG_FILE_GENERATOR6,
|
|
1836
|
+
PRETTIER_CONFIG_FILE_GENERATOR6,
|
|
1837
|
+
ESLINT_CONFIG_FILE_GENERATOR6,
|
|
1838
|
+
VITEST_CONFIG_FILE_GENERATOR6
|
|
1648
1839
|
]
|
|
1649
1840
|
);
|
|
1650
1841
|
await generator.generate();
|
|
1651
1842
|
}
|
|
1652
|
-
function
|
|
1843
|
+
function makeAppPackageGenerator3(packageName, namespace) {
|
|
1653
1844
|
const packageJsonModel = new PackageJSON({
|
|
1654
1845
|
name: packageName,
|
|
1655
1846
|
dependencies: [
|
|
@@ -1685,9 +1876,31 @@ function makeAppPackageGenerator(packageName, namespace) {
|
|
|
1685
1876
|
return new PackageJsonGenerator(packageJsonModel, namespace);
|
|
1686
1877
|
}
|
|
1687
1878
|
|
|
1879
|
+
// src/packages/create-config-package.ts
|
|
1880
|
+
var import_node_path5 = __toESM(require("path"));
|
|
1881
|
+
async function createConfigPackage(name) {
|
|
1882
|
+
const rootDir = await getWorkspaceRoot();
|
|
1883
|
+
const directory = import_node_path5.default.join(rootDir, "configs", name);
|
|
1884
|
+
const namespace = await getNamespace(rootDir);
|
|
1885
|
+
const packageName = `${namespace}/${name}`;
|
|
1886
|
+
const packageJsonModel = new PackageJSON({
|
|
1887
|
+
name: packageName,
|
|
1888
|
+
additionalData: {
|
|
1889
|
+
version: "0.1.0",
|
|
1890
|
+
private: true
|
|
1891
|
+
}
|
|
1892
|
+
});
|
|
1893
|
+
const generator = new PackageGenerator(
|
|
1894
|
+
directory,
|
|
1895
|
+
new PackageJsonGenerator(packageJsonModel, namespace),
|
|
1896
|
+
[]
|
|
1897
|
+
);
|
|
1898
|
+
await generator.generate();
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1688
1901
|
// src/unlink-packages.ts
|
|
1689
1902
|
var import_promises5 = __toESM(require("fs/promises"));
|
|
1690
|
-
var
|
|
1903
|
+
var import_node_path6 = __toESM(require("path"));
|
|
1691
1904
|
async function unlinkPackages(current, target) {
|
|
1692
1905
|
await updatePackageJSON2(current, target);
|
|
1693
1906
|
await updateTSConfig2(current, target);
|
|
@@ -1700,7 +1913,7 @@ async function updatePackageJSON2(current, target) {
|
|
|
1700
1913
|
await import_promises5.default.writeFile(packageJSONPath, updated.format(namespace));
|
|
1701
1914
|
}
|
|
1702
1915
|
async function updateTSConfig2(current, target) {
|
|
1703
|
-
const tsconfigPath =
|
|
1916
|
+
const tsconfigPath = import_node_path6.default.join(current.directory, "tsconfig.json");
|
|
1704
1917
|
const tsconfigContents = await import_promises5.default.readFile(tsconfigPath, "utf8");
|
|
1705
1918
|
const tsconfig = TSConfig.parse(tsconfigContents);
|
|
1706
1919
|
const updatedPaths = Object.fromEntries(
|
|
@@ -1713,9 +1926,156 @@ async function updateTSConfig2(current, target) {
|
|
|
1713
1926
|
await import_promises5.default.writeFile(tsconfigPath, updated.format());
|
|
1714
1927
|
}
|
|
1715
1928
|
|
|
1929
|
+
// src/utils/package.ts
|
|
1930
|
+
var import_fast_glob = require("fast-glob");
|
|
1931
|
+
var import_node_path7 = __toESM(require("path"));
|
|
1932
|
+
async function getCurrentPackage(directory = process.cwd()) {
|
|
1933
|
+
const packageRoot = await getPackageRoot(directory);
|
|
1934
|
+
const packageJson = await getDirectoryPackageJson(packageRoot);
|
|
1935
|
+
return getPackageByName(packageJson.name);
|
|
1936
|
+
}
|
|
1937
|
+
async function getPackageRoot(directory = process.cwd()) {
|
|
1938
|
+
const parent = import_node_path7.default.dirname(directory);
|
|
1939
|
+
if (parent === directory) {
|
|
1940
|
+
throw new Error("Not a package.");
|
|
1941
|
+
}
|
|
1942
|
+
if (await isPackageRoot(directory)) {
|
|
1943
|
+
return directory;
|
|
1944
|
+
}
|
|
1945
|
+
return getPackageRoot(parent);
|
|
1946
|
+
}
|
|
1947
|
+
async function getPackageByName(name) {
|
|
1948
|
+
const all = await getAllPackages();
|
|
1949
|
+
const match = all.find((p) => p.name === name);
|
|
1950
|
+
if (match === void 0) {
|
|
1951
|
+
throw new Error(`No package with name "${name}".`);
|
|
1952
|
+
}
|
|
1953
|
+
return match;
|
|
1954
|
+
}
|
|
1955
|
+
async function getAllPackages(directory = process.cwd()) {
|
|
1956
|
+
const workspaceRoot = await getWorkspaceRoot(directory);
|
|
1957
|
+
const workspaceFile = await getDirectoryWorkspaceFile(workspaceRoot);
|
|
1958
|
+
const results = [];
|
|
1959
|
+
for (const seg of workspaceFile.packages) {
|
|
1960
|
+
const packageType = getPackageType(seg);
|
|
1961
|
+
const packageJsonPaths = await (0, import_fast_glob.glob)(`${workspaceRoot}/${seg}/package.json`);
|
|
1962
|
+
const packageDirectories = packageJsonPaths.map((p) => import_node_path7.default.dirname(p));
|
|
1963
|
+
for (const directory2 of packageDirectories) {
|
|
1964
|
+
const name = (await getDirectoryPackageJson(directory2)).name;
|
|
1965
|
+
results.push({
|
|
1966
|
+
name,
|
|
1967
|
+
directory: directory2,
|
|
1968
|
+
type: packageType
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
return results;
|
|
1973
|
+
}
|
|
1974
|
+
function getPackageType(segment) {
|
|
1975
|
+
if (segment.startsWith("app")) {
|
|
1976
|
+
return "App";
|
|
1977
|
+
} else if (segment.startsWith("config")) {
|
|
1978
|
+
return "Config";
|
|
1979
|
+
} else if (segment.startsWith("package") || segment.startsWith("lib")) {
|
|
1980
|
+
return "Library";
|
|
1981
|
+
} else {
|
|
1982
|
+
return "Unknown";
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
function comparePackages(a, b) {
|
|
1986
|
+
const packageTypeDifference = comparePackageTypes(a.type, b.type);
|
|
1987
|
+
if (packageTypeDifference !== 0) {
|
|
1988
|
+
return packageTypeDifference;
|
|
1989
|
+
} else {
|
|
1990
|
+
return a.name.localeCompare(b.name);
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
function comparePackageTypes(a, b) {
|
|
1994
|
+
return getPackageTypeIndex(a) - getPackageTypeIndex(b);
|
|
1995
|
+
}
|
|
1996
|
+
function getPackageTypeIndex(packageType) {
|
|
1997
|
+
switch (packageType) {
|
|
1998
|
+
case "Library":
|
|
1999
|
+
return 0;
|
|
2000
|
+
case "Config":
|
|
2001
|
+
return 1;
|
|
2002
|
+
case "App":
|
|
2003
|
+
return 2;
|
|
2004
|
+
case "Unknown":
|
|
2005
|
+
return 3;
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
async function isPackageRoot(directory) {
|
|
2009
|
+
return await fileExists(import_node_path7.default.join(directory, "package.json"));
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
// src/utils/package-type.ts
|
|
2013
|
+
var import_enquirer = require("enquirer");
|
|
2014
|
+
var packageTypes = [
|
|
2015
|
+
"library",
|
|
2016
|
+
"config",
|
|
2017
|
+
"react",
|
|
2018
|
+
"vite",
|
|
2019
|
+
"fastify",
|
|
2020
|
+
"next",
|
|
2021
|
+
"cli"
|
|
2022
|
+
];
|
|
2023
|
+
async function pickPackageType(options) {
|
|
2024
|
+
if (options?.type && isPackageType(options.type)) {
|
|
2025
|
+
return options.type;
|
|
2026
|
+
} else if (options?.type && !isPackageType(options.type)) {
|
|
2027
|
+
throw new Error(
|
|
2028
|
+
`--type setting "${options.type}" is invalid, must be one of ${packageTypes.join(", ")}.`
|
|
2029
|
+
);
|
|
2030
|
+
}
|
|
2031
|
+
const response = await (0, import_enquirer.prompt)({
|
|
2032
|
+
type: "select",
|
|
2033
|
+
name: "type",
|
|
2034
|
+
message: "What kind of package do you want?",
|
|
2035
|
+
choices: [...packageTypes]
|
|
2036
|
+
});
|
|
2037
|
+
if (!isPackageType(response.type)) {
|
|
2038
|
+
throw new Error(
|
|
2039
|
+
`Type "${response.type}" is invalid, must be one of ${packageTypes.join(", ")}.`
|
|
2040
|
+
);
|
|
2041
|
+
}
|
|
2042
|
+
return response.type;
|
|
2043
|
+
}
|
|
2044
|
+
function isPackageType(s) {
|
|
2045
|
+
return packageTypes.some((p) => p === s);
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
// src/utils/style-type.ts
|
|
2049
|
+
var import_enquirer2 = require("enquirer");
|
|
2050
|
+
var styleTypes = ["styled-components", "none"];
|
|
2051
|
+
async function pickStyleType(options) {
|
|
2052
|
+
if (options?.style && isStyleType(options?.style)) {
|
|
2053
|
+
return options?.style;
|
|
2054
|
+
} else if (options?.style && !isStyleType(options?.style)) {
|
|
2055
|
+
throw new Error(
|
|
2056
|
+
`--style setting "${options.style}" is invalid, must be one of ${styleTypes.join(", ")}.`
|
|
2057
|
+
);
|
|
2058
|
+
}
|
|
2059
|
+
const response = await (0, import_enquirer2.prompt)({
|
|
2060
|
+
type: "select",
|
|
2061
|
+
name: "type",
|
|
2062
|
+
message: "What kind of style do you want?",
|
|
2063
|
+
choices: [...styleTypes]
|
|
2064
|
+
});
|
|
2065
|
+
if (!isStyleType(response.type)) {
|
|
2066
|
+
throw new Error(
|
|
2067
|
+
`Type "${response.type}" is invalid, must be one of ${styleTypes.join(", ")}.`
|
|
2068
|
+
);
|
|
2069
|
+
}
|
|
2070
|
+
return response.type;
|
|
2071
|
+
}
|
|
2072
|
+
function isStyleType(s) {
|
|
2073
|
+
return styleTypes.some((p) => p === s);
|
|
2074
|
+
}
|
|
2075
|
+
|
|
1716
2076
|
// src/workspace/create-workspace.ts
|
|
1717
2077
|
var import_promises6 = __toESM(require("fs/promises"));
|
|
1718
|
-
var
|
|
2078
|
+
var import_path8 = __toESM(require("path"));
|
|
1719
2079
|
|
|
1720
2080
|
// src/workspace/root-package.ts
|
|
1721
2081
|
async function makeRootPackage(directory, name) {
|
|
@@ -1902,7 +2262,7 @@ vite.config.ts.timestamp-*
|
|
|
1902
2262
|
`;
|
|
1903
2263
|
|
|
1904
2264
|
// src/workspace/typescript-config.ts
|
|
1905
|
-
var
|
|
2265
|
+
var import_path7 = __toESM(require("path"));
|
|
1906
2266
|
async function makeTypescriptConfig(directory, namespace) {
|
|
1907
2267
|
const packageJsonModel = new PackageJSON({
|
|
1908
2268
|
name: `${namespace}/typescript-config`,
|
|
@@ -1913,7 +2273,7 @@ async function makeTypescriptConfig(directory, namespace) {
|
|
|
1913
2273
|
files: ["*.json"]
|
|
1914
2274
|
}
|
|
1915
2275
|
});
|
|
1916
|
-
const fullPath =
|
|
2276
|
+
const fullPath = import_path7.default.join(directory, "configs/typescript-config");
|
|
1917
2277
|
return new PackageGenerator(
|
|
1918
2278
|
fullPath,
|
|
1919
2279
|
new PackageJsonGenerator(packageJsonModel, namespace),
|
|
@@ -1977,7 +2337,7 @@ var NODE = new FileGeneratorImp(
|
|
|
1977
2337
|
async function createWorkspace(name, directory) {
|
|
1978
2338
|
await validateNotInWorkspace(directory);
|
|
1979
2339
|
console.log(`\u2728 Creating workspace: @${name}`);
|
|
1980
|
-
const fullPath =
|
|
2340
|
+
const fullPath = import_path8.default.join(directory, name);
|
|
1981
2341
|
await import_promises6.default.mkdir(fullPath, { recursive: true });
|
|
1982
2342
|
const namespace = `@${name}`;
|
|
1983
2343
|
const PACKAGES = [
|
|
@@ -1985,9 +2345,9 @@ async function createWorkspace(name, directory) {
|
|
|
1985
2345
|
await makeTypescriptConfig(fullPath, namespace)
|
|
1986
2346
|
];
|
|
1987
2347
|
await Promise.all(PACKAGES.map((p) => p.generate()));
|
|
1988
|
-
await import_promises6.default.mkdir(
|
|
1989
|
-
await import_promises6.default.mkdir(
|
|
1990
|
-
await import_promises6.default.mkdir(
|
|
2348
|
+
await import_promises6.default.mkdir(import_path8.default.join(fullPath, "apps"));
|
|
2349
|
+
await import_promises6.default.mkdir(import_path8.default.join(fullPath, "configs"));
|
|
2350
|
+
await import_promises6.default.mkdir(import_path8.default.join(fullPath, "packages"));
|
|
1991
2351
|
console.log(`\u2705 Workspace created at: ${fullPath}`);
|
|
1992
2352
|
console.log("");
|
|
1993
2353
|
console.log(`Run "cd ${fullPath}" followed by "pnpm install"`);
|
|
@@ -2029,8 +2389,10 @@ program.command("g <name>").description("Generate a new package or app").option(
|
|
|
2029
2389
|
await createViteReactApp(name);
|
|
2030
2390
|
break;
|
|
2031
2391
|
case "cli":
|
|
2392
|
+
await createCliApp(name);
|
|
2032
2393
|
break;
|
|
2033
2394
|
case "fastify":
|
|
2395
|
+
await createFastifyApp(name);
|
|
2034
2396
|
break;
|
|
2035
2397
|
case "next":
|
|
2036
2398
|
break;
|
|
@@ -2041,7 +2403,7 @@ program.command("g <name>").description("Generate a new package or app").option(
|
|
|
2041
2403
|
program.command("link [name]").alias("l").option("-D, --dev", "Whether to link as a devDependency.", false).description("Link to the specified package").action(async (name, options) => {
|
|
2042
2404
|
name = name ?? await promptForPackageToLinkTo();
|
|
2043
2405
|
const development = options.dev ?? false;
|
|
2044
|
-
if (!isValidPackageName(name)) {
|
|
2406
|
+
if (!await isValidPackageName(name)) {
|
|
2045
2407
|
throw new Error(`Package name "${name}" is not a valid option.`);
|
|
2046
2408
|
}
|
|
2047
2409
|
const current = await getCurrentPackage();
|