@jskit-ai/create-app 0.1.1 → 0.1.3

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": "@jskit-ai/create-app",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Scaffold minimal JSKIT app shells.",
5
5
  "type": "module",
6
6
  "files": [
@@ -10,29 +10,33 @@
10
10
  "README.md"
11
11
  ],
12
12
  "scripts": {
13
- "test": "node --test"
13
+ "test": "node --test test/*.test.js"
14
14
  },
15
15
  "bin": {
16
16
  "jskit-create-app": "bin/jskit-create-app.js"
17
17
  },
18
18
  "exports": {
19
- ".": "./src/shared/index.js"
19
+ ".": "./src/index.js",
20
+ "./server": "./src/server/index.js",
21
+ "./client": "./src/client/index.js"
20
22
  },
23
+ "dependencies": {},
21
24
  "engines": {
22
25
  "node": "20.x"
23
26
  },
24
27
  "publishConfig": {
25
- "access": "public"
28
+ "access": "public",
29
+ "registry": "https://registry.npmjs.org/"
26
30
  },
27
31
  "repository": {
28
32
  "type": "git",
29
33
  "url": "git+https://github.com/mobily-enterprises/jskit-ai.git",
30
- "directory": "packages/tooling/create-app"
34
+ "directory": "tooling/create-app"
31
35
  },
32
36
  "bugs": {
33
37
  "url": "https://github.com/mobily-enterprises/jskit-ai/issues"
34
38
  },
35
- "homepage": "https://github.com/mobily-enterprises/jskit-ai/tree/main/packages/tooling/create-app#readme",
39
+ "homepage": "https://github.com/mobily-enterprises/jskit-ai/tree/main/tooling/create-app#readme",
36
40
  "keywords": [
37
41
  "jskit",
38
42
  "scaffold",
package/README.md DELETED
@@ -1,24 +0,0 @@
1
- # @jskit-ai/create-app
2
-
3
- Scaffold a minimal JSKIT app shell from in-repo templates.
4
-
5
- ## Usage
6
-
7
- ```bash
8
- jskit-create-app my-app
9
- ```
10
-
11
- ```bash
12
- jskit-create-app --interactive
13
- ```
14
-
15
- ## Options
16
-
17
- - `--template <name>` template name under `templates/` (default `base-shell`)
18
- - `--title <text>` override the generated app title placeholder
19
- - `--target <path>` output directory (default `./<app-name>`)
20
- - `--initial-bundles <preset>` optional framework preset: `none`, `db`, or `db-auth`
21
- - `--db-provider <provider>` provider for `db` presets: `mysql` or `postgres`
22
- - `--force` allow writes into non-empty target directories
23
- - `--dry-run` preview writes only
24
- - `--interactive` prompt for app values
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
- import process from "node:process";
3
- import { runCli } from "../src/shared/index.js";
4
-
5
- const exitCode = await runCli(process.argv.slice(2));
6
- if (exitCode !== 0) {
7
- process.exit(exitCode);
8
- }
@@ -1,647 +0,0 @@
1
- import { chmod, mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
2
- import path from "node:path";
3
- import process from "node:process";
4
- import { createInterface } from "node:readline/promises";
5
- import { fileURLToPath } from "node:url";
6
-
7
- const DEFAULT_TEMPLATE = "base-shell";
8
- const DEFAULT_INITIAL_BUNDLES = "none";
9
- const DEFAULT_DB_PROVIDER = "mysql";
10
- const INITIAL_BUNDLE_PRESETS = new Set(["none", "db", "db-auth"]);
11
- const DB_PROVIDERS = new Set(["mysql", "postgres"]);
12
- const ALLOWED_EXISTING_TARGET_ENTRIES = new Set([".git"]);
13
- const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
14
- const TEMPLATES_ROOT = path.join(PACKAGE_ROOT, "templates");
15
-
16
- function createCliError(message, { showUsage = false, exitCode = 1 } = {}) {
17
- const error = new Error(String(message || "Command failed."));
18
- error.showUsage = Boolean(showUsage);
19
- error.exitCode = Number.isInteger(exitCode) ? exitCode : 1;
20
- return error;
21
- }
22
-
23
- function shellQuote(value) {
24
- const raw = String(value ?? "");
25
- if (!raw) {
26
- return "''";
27
- }
28
- if (/^[A-Za-z0-9_./:=+,-]+$/.test(raw)) {
29
- return raw;
30
- }
31
- return `'${raw.replace(/'/g, "'\\''")}'`;
32
- }
33
-
34
- function toAppTitle(appName) {
35
- const words = String(appName)
36
- .trim()
37
- .split(/[-_]+/)
38
- .filter(Boolean)
39
- .map((word) => `${word.slice(0, 1).toUpperCase()}${word.slice(1)}`);
40
-
41
- return words.length > 0 ? words.join(" ") : "App";
42
- }
43
-
44
- function normalizeInitialBundlesPreset(value, { showUsage = true } = {}) {
45
- const normalized = String(value || DEFAULT_INITIAL_BUNDLES).trim().toLowerCase();
46
- if (INITIAL_BUNDLE_PRESETS.has(normalized)) {
47
- return normalized;
48
- }
49
-
50
- throw createCliError(
51
- `Invalid --initial-bundles value "${value}". Expected one of: none, db, db-auth.`,
52
- { showUsage }
53
- );
54
- }
55
-
56
- function normalizeDbProvider(value, { showUsage = true } = {}) {
57
- const normalized = String(value || DEFAULT_DB_PROVIDER).trim().toLowerCase();
58
- if (DB_PROVIDERS.has(normalized)) {
59
- return normalized;
60
- }
61
-
62
- throw createCliError(
63
- `Invalid --db-provider value "${value}". Expected one of: mysql, postgres.`,
64
- { showUsage }
65
- );
66
- }
67
-
68
- function buildInitialBundleCommands(initialBundles, dbProvider) {
69
- const normalizedPreset = normalizeInitialBundlesPreset(initialBundles, { showUsage: false });
70
- const normalizedProvider = normalizeDbProvider(dbProvider, { showUsage: false });
71
-
72
- const commands = [];
73
- if (normalizedPreset === "db" || normalizedPreset === "db-auth") {
74
- commands.push(`npx jskit add db --provider ${normalizedProvider} --no-install`);
75
- }
76
- if (normalizedPreset === "db-auth") {
77
- commands.push("npx jskit add auth-base --no-install");
78
- }
79
-
80
- return commands;
81
- }
82
-
83
- function buildProgressiveBundleCommands(dbProvider) {
84
- const normalizedProvider = normalizeDbProvider(dbProvider, { showUsage: false });
85
- return [
86
- `npx jskit add db --provider ${normalizedProvider} --no-install`,
87
- "npx jskit add auth-base --no-install"
88
- ];
89
- }
90
-
91
- function validateAppName(appName, { showUsage = true } = {}) {
92
- if (!appName || typeof appName !== "string") {
93
- throw createCliError("Missing app name.", { showUsage });
94
- }
95
-
96
- if (!/^[a-z0-9][a-z0-9-]*$/.test(appName)) {
97
- throw createCliError(
98
- `Invalid app name "${appName}". Use lowercase letters, numbers, and dashes only.`,
99
- { showUsage }
100
- );
101
- }
102
- }
103
-
104
- function parseOptionWithValue(argv, index, optionName) {
105
- const nextValue = argv[index + 1];
106
- if (!nextValue || nextValue.startsWith("-")) {
107
- throw createCliError(`Option ${optionName} requires a value.`, {
108
- showUsage: true
109
- });
110
- }
111
- return {
112
- value: nextValue,
113
- nextIndex: index + 1
114
- };
115
- }
116
-
117
- function parseCliArgs(argv) {
118
- const args = Array.isArray(argv) ? argv : [];
119
- const options = {
120
- appName: null,
121
- appTitle: null,
122
- template: DEFAULT_TEMPLATE,
123
- target: null,
124
- initialBundles: DEFAULT_INITIAL_BUNDLES,
125
- dbProvider: DEFAULT_DB_PROVIDER,
126
- force: false,
127
- dryRun: false,
128
- help: false,
129
- interactive: false
130
- };
131
-
132
- const positionalArgs = [];
133
-
134
- for (let index = 0; index < args.length; index += 1) {
135
- const arg = String(args[index] || "");
136
-
137
- if (arg === "--help" || arg === "-h") {
138
- options.help = true;
139
- continue;
140
- }
141
-
142
- if (arg === "--force") {
143
- options.force = true;
144
- continue;
145
- }
146
-
147
- if (arg === "--dry-run") {
148
- options.dryRun = true;
149
- continue;
150
- }
151
-
152
- if (arg === "--interactive") {
153
- options.interactive = true;
154
- continue;
155
- }
156
-
157
- if (arg === "--template") {
158
- const { value, nextIndex } = parseOptionWithValue(args, index, "--template");
159
- options.template = value;
160
- index = nextIndex;
161
- continue;
162
- }
163
-
164
- if (arg.startsWith("--template=")) {
165
- options.template = arg.slice("--template=".length);
166
- continue;
167
- }
168
-
169
- if (arg === "--target") {
170
- const { value, nextIndex } = parseOptionWithValue(args, index, "--target");
171
- options.target = value;
172
- index = nextIndex;
173
- continue;
174
- }
175
-
176
- if (arg.startsWith("--target=")) {
177
- options.target = arg.slice("--target=".length);
178
- continue;
179
- }
180
-
181
- if (arg === "--title") {
182
- const { value, nextIndex } = parseOptionWithValue(args, index, "--title");
183
- options.appTitle = value;
184
- index = nextIndex;
185
- continue;
186
- }
187
-
188
- if (arg.startsWith("--title=")) {
189
- options.appTitle = arg.slice("--title=".length);
190
- continue;
191
- }
192
-
193
- if (arg === "--initial-bundles") {
194
- const { value, nextIndex } = parseOptionWithValue(args, index, "--initial-bundles");
195
- options.initialBundles = value;
196
- index = nextIndex;
197
- continue;
198
- }
199
-
200
- if (arg.startsWith("--initial-bundles=")) {
201
- options.initialBundles = arg.slice("--initial-bundles=".length);
202
- continue;
203
- }
204
-
205
- if (arg === "--db-provider") {
206
- const { value, nextIndex } = parseOptionWithValue(args, index, "--db-provider");
207
- options.dbProvider = value;
208
- index = nextIndex;
209
- continue;
210
- }
211
-
212
- if (arg.startsWith("--db-provider=")) {
213
- options.dbProvider = arg.slice("--db-provider=".length);
214
- continue;
215
- }
216
-
217
- if (arg.startsWith("-")) {
218
- throw createCliError(`Unknown option: ${arg}`, {
219
- showUsage: true
220
- });
221
- }
222
-
223
- positionalArgs.push(arg);
224
- }
225
-
226
- if (positionalArgs.length > 1) {
227
- throw createCliError("Only one <app-name> argument is allowed.", {
228
- showUsage: true
229
- });
230
- }
231
-
232
- if (positionalArgs.length === 1) {
233
- options.appName = positionalArgs[0];
234
- }
235
-
236
- if (!options.help && !options.interactive && positionalArgs.length !== 1) {
237
- throw createCliError("Expected exactly one <app-name> argument.", {
238
- showUsage: true
239
- });
240
- }
241
-
242
- return options;
243
- }
244
-
245
- function printUsage(stream = process.stderr) {
246
- stream.write("Usage: jskit-create-app [app-name] [options]\n");
247
- stream.write("\n");
248
- stream.write("Options:\n");
249
- stream.write(` --template <name> Template folder under templates/ (default: ${DEFAULT_TEMPLATE})\n`);
250
- stream.write(" --title <text> App title used for template replacements\n");
251
- stream.write(" --target <path> Target directory (default: ./<app-name>)\n");
252
- stream.write(" --initial-bundles <preset> Optional bundle preset: none | db | db-auth (default: none)\n");
253
- stream.write(" --db-provider <provider> Database provider for db presets: mysql | postgres (default: mysql)\n");
254
- stream.write(" --force Allow writing into a non-empty target directory\n");
255
- stream.write(" --dry-run Print planned writes without changing the filesystem\n");
256
- stream.write(" --interactive Prompt for app values instead of passing all flags\n");
257
- stream.write(" -h, --help Show this help\n");
258
- }
259
-
260
- function applyPlaceholders(source, replacements) {
261
- let output = String(source || "");
262
- for (const [placeholder, value] of Object.entries(replacements)) {
263
- output = output.split(placeholder).join(String(value));
264
- }
265
- return output;
266
- }
267
-
268
- async function resolveTemplateDirectory(templateName) {
269
- const cleanTemplate = String(templateName || "").trim();
270
- if (!cleanTemplate) {
271
- throw createCliError("Template name cannot be empty.", {
272
- showUsage: true
273
- });
274
- }
275
-
276
- const templateDir = path.join(TEMPLATES_ROOT, cleanTemplate);
277
-
278
- try {
279
- const templateStats = await stat(templateDir);
280
- if (!templateStats.isDirectory()) {
281
- throw createCliError(`Template "${cleanTemplate}" is not a directory.`);
282
- }
283
- } catch (error) {
284
- if (error?.code === "ENOENT") {
285
- throw createCliError(`Unknown template "${cleanTemplate}".`);
286
- }
287
- throw error;
288
- }
289
-
290
- return templateDir;
291
- }
292
-
293
- async function ensureTargetDirectoryState(targetDirectory, { force = false, dryRun = false } = {}) {
294
- let targetExists = false;
295
-
296
- try {
297
- const targetStats = await stat(targetDirectory);
298
- targetExists = true;
299
- if (!targetStats.isDirectory()) {
300
- throw createCliError(`Target path exists and is not a directory: ${targetDirectory}`);
301
- }
302
- } catch (error) {
303
- if (error?.code !== "ENOENT") {
304
- throw error;
305
- }
306
- }
307
-
308
- if (!targetExists) {
309
- if (!dryRun) {
310
- await mkdir(targetDirectory, { recursive: true });
311
- }
312
- return;
313
- }
314
-
315
- const entries = await readdir(targetDirectory);
316
- const blockingEntries = entries.filter((entry) => !ALLOWED_EXISTING_TARGET_ENTRIES.has(entry));
317
- if (blockingEntries.length > 0 && !force) {
318
- throw createCliError(
319
- `Target directory is not empty: ${targetDirectory}. Use --force to allow writing into it.`
320
- );
321
- }
322
- }
323
-
324
- function sortEntriesByName(entries) {
325
- return [...entries].sort((left, right) => left.name.localeCompare(right.name));
326
- }
327
-
328
- function mapTemplatePathToTargetPath(relativePath) {
329
- const pathSegments = String(relativePath || "")
330
- .split(path.sep)
331
- .map((segment) => (segment === "gitignore" ? ".gitignore" : segment));
332
- return pathSegments.join(path.sep);
333
- }
334
-
335
- async function writeTemplateFile(sourcePath, targetPath, replacements) {
336
- const sourceBody = await readFile(sourcePath, "utf8");
337
- const targetBody = applyPlaceholders(sourceBody, replacements);
338
-
339
- await mkdir(path.dirname(targetPath), { recursive: true });
340
- await writeFile(targetPath, targetBody, "utf8");
341
-
342
- const sourceStats = await stat(sourcePath);
343
- await chmod(targetPath, sourceStats.mode & 0o777);
344
- }
345
-
346
- async function copyTemplateDirectory({ templateDirectory, targetDirectory, replacements, dryRun }) {
347
- const touchedFiles = [];
348
-
349
- async function traverse(relativePath = "") {
350
- const sourceDirectory = path.join(templateDirectory, relativePath);
351
- const sourceEntries = sortEntriesByName(await readdir(sourceDirectory, { withFileTypes: true }));
352
-
353
- for (const entry of sourceEntries) {
354
- const entryRelativePath = relativePath ? path.join(relativePath, entry.name) : entry.name;
355
- const targetRelativePath = mapTemplatePathToTargetPath(entryRelativePath);
356
- const sourcePath = path.join(templateDirectory, entryRelativePath);
357
- const targetPath = path.join(targetDirectory, targetRelativePath);
358
-
359
- if (entry.isDirectory()) {
360
- if (!dryRun) {
361
- await mkdir(targetPath, { recursive: true });
362
- }
363
- await traverse(entryRelativePath);
364
- continue;
365
- }
366
-
367
- if (entry.isFile()) {
368
- touchedFiles.push(targetRelativePath);
369
- if (!dryRun) {
370
- await writeTemplateFile(sourcePath, targetPath, replacements);
371
- }
372
- continue;
373
- }
374
-
375
- throw createCliError(`Unsupported template entry type at ${entryRelativePath}.`);
376
- }
377
- }
378
-
379
- await traverse();
380
- return touchedFiles;
381
- }
382
-
383
- function toRelativeTargetLabel(cwd, targetDirectory) {
384
- const relativePath = path.relative(cwd, targetDirectory);
385
- if (!relativePath || relativePath === ".") {
386
- return ".";
387
- }
388
- if (relativePath.startsWith("..")) {
389
- return targetDirectory;
390
- }
391
- return `./${relativePath}`;
392
- }
393
-
394
- async function askQuestion(readline, label, defaultValue) {
395
- const suffix = defaultValue ? ` (${defaultValue})` : "";
396
- const response = await readline.question(`${label}${suffix}: `);
397
- const trimmed = response.trim();
398
- return trimmed || defaultValue;
399
- }
400
-
401
- async function askYesNoQuestion(readline, label, defaultValue) {
402
- const prompt = defaultValue ? "Y/n" : "y/N";
403
-
404
- while (true) {
405
- const response = await readline.question(`${label} [${prompt}]: `);
406
- const normalized = response.trim().toLowerCase();
407
- if (!normalized) {
408
- return defaultValue;
409
- }
410
- if (normalized === "y" || normalized === "yes") {
411
- return true;
412
- }
413
- if (normalized === "n" || normalized === "no") {
414
- return false;
415
- }
416
- }
417
- }
418
-
419
- function createReadlineInterface({ stdin = process.stdin, stdout = process.stdout } = {}) {
420
- return createInterface({
421
- input: stdin,
422
- output: stdout
423
- });
424
- }
425
-
426
- async function collectInteractiveOptions({
427
- parsed,
428
- stdout = process.stdout,
429
- stderr = process.stderr,
430
- stdin = process.stdin,
431
- readlineFactory = createReadlineInterface
432
- }) {
433
- const readline = readlineFactory({
434
- stdin,
435
- stdout
436
- });
437
-
438
- try {
439
- let appName = String(parsed.appName || "").trim();
440
- while (true) {
441
- appName = await askQuestion(readline, "App name", appName);
442
- try {
443
- validateAppName(appName, { showUsage: false });
444
- break;
445
- } catch (error) {
446
- stderr.write(`Error: ${error?.message || String(error)}\n`);
447
- }
448
- }
449
-
450
- const defaultTitle = String(parsed.appTitle || "").trim() || toAppTitle(appName);
451
- const appTitle = await askQuestion(readline, "App title", defaultTitle);
452
-
453
- const defaultTarget = String(parsed.target || "").trim() || appName;
454
- const target = await askQuestion(readline, "Target directory", defaultTarget);
455
-
456
- const defaultTemplate = String(parsed.template || "").trim() || DEFAULT_TEMPLATE;
457
- const template = await askQuestion(readline, "Template", defaultTemplate);
458
-
459
- const force = await askYesNoQuestion(
460
- readline,
461
- "Allow writing into non-empty target directories",
462
- Boolean(parsed.force)
463
- );
464
-
465
- let initialBundles = normalizeInitialBundlesPreset(parsed.initialBundles, { showUsage: false });
466
- while (true) {
467
- const candidate = await askQuestion(
468
- readline,
469
- "Initial bundle preset (none|db|db-auth)",
470
- initialBundles
471
- );
472
- try {
473
- initialBundles = normalizeInitialBundlesPreset(candidate, { showUsage: false });
474
- break;
475
- } catch (error) {
476
- stderr.write(`Error: ${error?.message || String(error)}\n`);
477
- }
478
- }
479
-
480
- let dbProvider = normalizeDbProvider(parsed.dbProvider, { showUsage: false });
481
- if (initialBundles === "db" || initialBundles === "db-auth") {
482
- while (true) {
483
- const candidate = await askQuestion(readline, "DB provider (mysql|postgres)", dbProvider);
484
- try {
485
- dbProvider = normalizeDbProvider(candidate, { showUsage: false });
486
- break;
487
- } catch (error) {
488
- stderr.write(`Error: ${error?.message || String(error)}\n`);
489
- }
490
- }
491
- }
492
-
493
- return {
494
- appName,
495
- appTitle,
496
- target,
497
- template,
498
- force,
499
- initialBundles,
500
- dbProvider
501
- };
502
- } finally {
503
- readline.close();
504
- }
505
- }
506
-
507
- export async function createApp({
508
- appName,
509
- appTitle = null,
510
- template = DEFAULT_TEMPLATE,
511
- target = null,
512
- initialBundles = DEFAULT_INITIAL_BUNDLES,
513
- dbProvider = DEFAULT_DB_PROVIDER,
514
- force = false,
515
- dryRun = false,
516
- cwd = process.cwd()
517
- }) {
518
- const resolvedAppName = String(appName || "").trim();
519
- validateAppName(resolvedAppName);
520
-
521
- const resolvedAppTitle = String(appTitle || "").trim() || toAppTitle(resolvedAppName);
522
- const resolvedInitialBundles = normalizeInitialBundlesPreset(initialBundles);
523
- const resolvedDbProvider = normalizeDbProvider(dbProvider);
524
-
525
- const resolvedCwd = path.resolve(cwd);
526
- const targetDirectory = path.resolve(resolvedCwd, target ? String(target) : resolvedAppName);
527
- const templateDirectory = await resolveTemplateDirectory(template);
528
-
529
- await ensureTargetDirectoryState(targetDirectory, {
530
- force,
531
- dryRun
532
- });
533
-
534
- const replacements = {
535
- __APP_NAME__: resolvedAppName,
536
- __APP_TITLE__: resolvedAppTitle
537
- };
538
-
539
- const touchedFiles = await copyTemplateDirectory({
540
- templateDirectory,
541
- targetDirectory,
542
- replacements,
543
- dryRun
544
- });
545
-
546
- return {
547
- appName: resolvedAppName,
548
- appTitle: resolvedAppTitle,
549
- template: String(template),
550
- initialBundles: resolvedInitialBundles,
551
- dbProvider: resolvedDbProvider,
552
- selectedBundleCommands: buildInitialBundleCommands(resolvedInitialBundles, resolvedDbProvider),
553
- progressiveBundleCommands: buildProgressiveBundleCommands(resolvedDbProvider),
554
- targetDirectory,
555
- dryRun,
556
- touchedFiles
557
- };
558
- }
559
-
560
- export async function runCli(
561
- argv,
562
- {
563
- stdout = process.stdout,
564
- stderr = process.stderr,
565
- stdin = process.stdin,
566
- cwd = process.cwd(),
567
- readlineFactory = createReadlineInterface
568
- } = {}
569
- ) {
570
- try {
571
- const parsed = parseCliArgs(argv);
572
-
573
- if (parsed.help) {
574
- printUsage(stdout);
575
- return 0;
576
- }
577
-
578
- const resolvedOptions = parsed.interactive
579
- ? {
580
- ...parsed,
581
- ...(await collectInteractiveOptions({
582
- parsed,
583
- stdout,
584
- stderr,
585
- stdin,
586
- readlineFactory
587
- }))
588
- }
589
- : parsed;
590
-
591
- const result = await createApp({
592
- appName: resolvedOptions.appName,
593
- appTitle: resolvedOptions.appTitle,
594
- template: resolvedOptions.template,
595
- target: resolvedOptions.target,
596
- initialBundles: resolvedOptions.initialBundles,
597
- dbProvider: resolvedOptions.dbProvider,
598
- force: resolvedOptions.force,
599
- dryRun: resolvedOptions.dryRun,
600
- cwd
601
- });
602
-
603
- const targetLabel = toRelativeTargetLabel(path.resolve(cwd), result.targetDirectory);
604
- if (result.dryRun) {
605
- stdout.write(
606
- `[dry-run] Would create app "${result.appName}" from template "${result.template}" at ${targetLabel}.\n`
607
- );
608
- } else {
609
- stdout.write(`Created app "${result.appName}" from template "${result.template}" at ${targetLabel}.\n`);
610
- }
611
-
612
- stdout.write(`${result.dryRun ? "Planned" : "Written"} files (${result.touchedFiles.length}):\n`);
613
- for (const filePath of result.touchedFiles) {
614
- stdout.write(`- ${filePath}\n`);
615
- }
616
-
617
- if (!result.dryRun) {
618
- stdout.write("\n");
619
- stdout.write("Next steps:\n");
620
- stdout.write(`- cd ${shellQuote(targetLabel)}\n`);
621
- stdout.write("- npm install\n");
622
- stdout.write("- npm run dev\n");
623
-
624
- stdout.write("\n");
625
- if (result.selectedBundleCommands.length > 0) {
626
- stdout.write(`Initial framework bundle commands (${result.initialBundles}):\n`);
627
- for (const command of result.selectedBundleCommands) {
628
- stdout.write(`- ${command}\n`);
629
- }
630
- } else {
631
- stdout.write("Add framework capabilities when ready:\n");
632
- for (const command of result.progressiveBundleCommands) {
633
- stdout.write(`- ${command}\n`);
634
- }
635
- }
636
- }
637
-
638
- return 0;
639
- } catch (error) {
640
- stderr.write(`Error: ${error?.message || String(error)}\n`);
641
- if (error?.showUsage) {
642
- stderr.write("\n");
643
- printUsage(stderr);
644
- }
645
- return Number.isInteger(error?.exitCode) ? error.exitCode : 1;
646
- }
647
- }
@@ -1 +0,0 @@
1
- web: npm run start
@@ -1,39 +0,0 @@
1
- # __APP_TITLE__
2
-
3
- Minimal JSKIT starter shell.
4
-
5
- ## What This Is
6
-
7
- This is the smallest practical JSKIT app host:
8
-
9
- - tiny Fastify server (`/api/v1/health`)
10
- - tiny Vue client shell
11
- - standardized scripts via `@jskit-ai/app-scripts`
12
-
13
- ## What This Is Not
14
-
15
- This app intentionally does not include:
16
-
17
- - db wiring
18
- - auth/workspace modules
19
- - billing/chat/social/ai modules
20
- - app-local framework composition engines
21
-
22
- Those are layered in later as framework packs/modules.
23
-
24
- ## Run
25
-
26
- ```bash
27
- npm install
28
- npm run dev
29
- npm run server
30
- npm run test
31
- npm run test:client
32
- ```
33
-
34
- ## Progressive Bundles
35
-
36
- ```bash
37
- npx jskit add db --provider mysql --no-install
38
- npx jskit add auth-base --no-install
39
- ```
@@ -1,3 +0,0 @@
1
- import { createNodeVueFastifyScriptsConfig } from "@jskit-ai/app-scripts";
2
-
3
- export default createNodeVueFastifyScriptsConfig();
@@ -1,8 +0,0 @@
1
- import { startServer } from "../server.js";
2
-
3
- try {
4
- await startServer();
5
- } catch (error) {
6
- console.error("Failed to start __APP_NAME__ server:", error);
7
- process.exitCode = 1;
8
- }
@@ -1,10 +0,0 @@
1
- import { baseConfig, nodeConfig, webConfig } from "@jskit-ai/config-eslint";
2
-
3
- export default [
4
- {
5
- ignores: ["dist/**", "node_modules/**", "coverage/**"]
6
- },
7
- ...baseConfig,
8
- ...webConfig,
9
- ...nodeConfig
10
- ];
@@ -1,7 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
- <rect width="64" height="64" rx="12" fill="#111827" />
3
- <path
4
- d="M20 16h24v8H28v20c0 6-4 10-10 10h-2v-8h2c2 0 2-1 2-3V16z"
5
- fill="#22d3ee"
6
- />
7
- </svg>
@@ -1,7 +0,0 @@
1
- node_modules/
2
- dist/
3
- coverage/
4
- test-results/
5
- .env
6
- .env.*
7
- !.env.example
@@ -1,13 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7
- <title>__APP_TITLE__</title>
8
- </head>
9
- <body>
10
- <div id="app"></div>
11
- <script type="module" src="/src/%VITE_CLIENT_ENTRY%"></script>
12
- </body>
13
- </html>
@@ -1,37 +0,0 @@
1
- {
2
- "name": "__APP_NAME__",
3
- "version": "0.1.0",
4
- "private": true,
5
- "type": "module",
6
- "description": "Minimal JSKIT base app (Fastify + Vue)",
7
- "engines": {
8
- "node": "20.x"
9
- },
10
- "bin": {
11
- "jskit": "node_modules/@jskit-ai/jskit/packages/tooling/jskit/bin/jskit.js"
12
- },
13
- "scripts": {
14
- "server": "jskit-app-scripts server",
15
- "start": "jskit-app-scripts start",
16
- "dev": "jskit-app-scripts dev",
17
- "build": "jskit-app-scripts build",
18
- "preview": "jskit-app-scripts preview",
19
- "lint": "jskit-app-scripts lint",
20
- "lint:process-env": "jskit-app-scripts lint:process-env",
21
- "test": "jskit-app-scripts test",
22
- "test:client": "jskit-app-scripts test:client"
23
- },
24
- "dependencies": {
25
- "@jskit-ai/app-scripts": "0.1.0",
26
- "fastify": "^5.7.4",
27
- "vue": "^3.5.13"
28
- },
29
- "devDependencies": {
30
- "@jskit-ai/config-eslint": "0.1.0",
31
- "@jskit-ai/jskit": "github:mobily-enterprises/jskit-ai",
32
- "@vitejs/plugin-vue": "^5.2.1",
33
- "eslint": "^9.39.1",
34
- "vite": "^6.1.0",
35
- "vitest": "^4.0.18"
36
- }
37
- }
@@ -1,16 +0,0 @@
1
- function toPort(value, fallback = 3000) {
2
- const parsed = Number.parseInt(String(value || "").trim(), 10);
3
- if (Number.isInteger(parsed) && parsed > 0) {
4
- return parsed;
5
- }
6
- return fallback;
7
- }
8
-
9
- function resolveRuntimeEnv() {
10
- return {
11
- PORT: toPort(process.env.PORT, 3000),
12
- HOST: String(process.env.HOST || "").trim() || "0.0.0.0"
13
- };
14
- }
15
-
16
- export { resolveRuntimeEnv };
@@ -1,26 +0,0 @@
1
- import Fastify from "fastify";
2
- import { resolveRuntimeEnv } from "./server/lib/runtimeEnv.js";
3
-
4
- function createServer() {
5
- const app = Fastify({ logger: true });
6
-
7
- app.get("/api/v1/health", async () => {
8
- return {
9
- ok: true,
10
- app: "__APP_NAME__"
11
- };
12
- });
13
-
14
- return app;
15
- }
16
-
17
- async function startServer(options = {}) {
18
- const runtimeEnv = resolveRuntimeEnv();
19
- const port = Number(options?.port) || runtimeEnv.PORT;
20
- const host = String(options?.host || "").trim() || runtimeEnv.HOST;
21
- const app = createServer();
22
- await app.listen({ port, host });
23
- return app;
24
- }
25
-
26
- export { createServer, startServer };
@@ -1,30 +0,0 @@
1
- import { createApp, onMounted, ref } from "vue";
2
-
3
- const App = {
4
- setup() {
5
- const health = ref("loading...");
6
-
7
- onMounted(async () => {
8
- try {
9
- const response = await fetch("/api/v1/health");
10
- const payload = await response.json();
11
- health.value = payload?.ok ? "ok" : "unhealthy";
12
- } catch {
13
- health.value = "unreachable";
14
- }
15
- });
16
-
17
- return {
18
- health
19
- };
20
- },
21
- template: `
22
- <main style="font-family: sans-serif; max-width: 48rem; margin: 3rem auto; padding: 0 1rem;">
23
- <h1>__APP_TITLE__</h1>
24
- <p>Minimal starter shell is running.</p>
25
- <p><strong>Health:</strong> {{ health }}</p>
26
- </main>
27
- `
28
- };
29
-
30
- createApp(App).mount("#app");
@@ -1,7 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
-
3
- describe("__APP_NAME__ client smoke", () => {
4
- it("runs vitest in __APP_NAME__", () => {
5
- expect(true).toBe(true);
6
- });
7
- });
@@ -1,93 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import path from "node:path";
4
- import { fileURLToPath } from "node:url";
5
- import { access, readdir, readFile } from "node:fs/promises";
6
-
7
- const __filename = fileURLToPath(import.meta.url);
8
- const __dirname = path.dirname(__filename);
9
- const APP_ROOT = path.resolve(__dirname, "../..");
10
-
11
- const EXPECTED_RUNTIME_DEPENDENCIES = Object.freeze([
12
- "@jskit-ai/app-scripts",
13
- "fastify",
14
- "vue"
15
- ]);
16
-
17
- const EXPECTED_DEV_DEPENDENCIES = Object.freeze([
18
- "@jskit-ai/config-eslint",
19
- "@jskit-ai/jskit",
20
- "@vitejs/plugin-vue",
21
- "eslint",
22
- "vite",
23
- "vitest"
24
- ]);
25
-
26
- const EXPECTED_TOP_LEVEL_ENTRIES = Object.freeze([
27
- "Procfile",
28
- "README.md",
29
- "app.scripts.config.mjs",
30
- "bin",
31
- "eslint.config.mjs",
32
- "favicon.svg",
33
- "gitignore",
34
- "index.html",
35
- "package.json",
36
- "server.js",
37
- "server",
38
- "src",
39
- "tests",
40
- "vite.config.mjs"
41
- ]);
42
-
43
- async function readPackageJson() {
44
- const packageJsonPath = path.join(APP_ROOT, "package.json");
45
- const raw = await readFile(packageJsonPath, "utf8");
46
- return JSON.parse(raw);
47
- }
48
-
49
- function sortStrings(values) {
50
- return [...values].sort((left, right) => left.localeCompare(right));
51
- }
52
-
53
- function sortedKeys(record) {
54
- return sortStrings(Object.keys(record || {}));
55
- }
56
-
57
- async function readTopLevelEntries() {
58
- const entries = await readdir(APP_ROOT, { withFileTypes: true });
59
- const ignored = new Set([
60
- "node_modules",
61
- "dist",
62
- "coverage",
63
- "test-results",
64
- "package-lock.json",
65
- "pnpm-lock.yaml",
66
- "yarn.lock"
67
- ]);
68
- return entries
69
- .map((entry) => entry.name)
70
- .filter((name) => !name.startsWith("."))
71
- .filter((name) => !ignored.has(name));
72
- }
73
-
74
- test("minimal shell keeps strict dependency allowlist", async () => {
75
- const packageJson = await readPackageJson();
76
- assert.deepEqual(
77
- sortedKeys(packageJson.dependencies),
78
- [...EXPECTED_RUNTIME_DEPENDENCIES].sort((left, right) => left.localeCompare(right))
79
- );
80
- assert.deepEqual(
81
- sortedKeys(packageJson.devDependencies),
82
- [...EXPECTED_DEV_DEPENDENCIES].sort((left, right) => left.localeCompare(right))
83
- );
84
- });
85
-
86
- test("starter shell keeps a strict top-level footprint", async () => {
87
- const entries = await readTopLevelEntries();
88
- assert.deepEqual(sortStrings(entries), sortStrings(EXPECTED_TOP_LEVEL_ENTRIES));
89
- });
90
-
91
- test("legacy app.manifest scaffold is removed from starter shell", async () => {
92
- await assert.rejects(access(path.join(APP_ROOT, "framework/app.manifest.mjs")), /ENOENT/);
93
- });
@@ -1,19 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import { createServer } from "../../server.js";
4
-
5
- test("GET /api/v1/health returns ok payload", async () => {
6
- const app = createServer();
7
- const response = await app.inject({
8
- method: "GET",
9
- url: "/api/v1/health"
10
- });
11
-
12
- assert.equal(response.statusCode, 200);
13
- assert.deepEqual(response.json(), {
14
- ok: true,
15
- app: "__APP_NAME__"
16
- });
17
-
18
- await app.close();
19
- });
@@ -1,29 +0,0 @@
1
- import { defineConfig } from "vite";
2
- import vue from "@vitejs/plugin-vue";
3
-
4
- function toPositiveInt(value, fallback) {
5
- const parsed = Number.parseInt(String(value || "").trim(), 10);
6
- if (Number.isInteger(parsed) && parsed > 0) {
7
- return parsed;
8
- }
9
- return fallback;
10
- }
11
-
12
- const devPort = toPositiveInt(process.env.VITE_DEV_PORT, 5173);
13
- const apiProxyTarget = String(process.env.VITE_API_PROXY_TARGET || "").trim() || "http://localhost:3000";
14
-
15
- export default defineConfig({
16
- plugins: [vue()],
17
- test: {
18
- include: ["tests/client/**/*.vitest.js"]
19
- },
20
- server: {
21
- port: devPort,
22
- proxy: {
23
- "/api": {
24
- target: apiProxyTarget,
25
- changeOrigin: true
26
- }
27
- }
28
- }
29
- });