@percepta/create 4.1.8 → 4.1.9
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/dist/index.js +80 -15
- package/dist/index.js.map +1 -1
- package/dist/{register-app-mNc1oYVK.js → register-app-B9vKTkoI.js} +87 -33
- package/dist/register-app-B9vKTkoI.js.map +1 -0
- package/package.json +1 -1
- package/templates/infra/os.blueprint.yaml.template +13 -0
- package/templates/monorepo/auth/README.md +2 -2
- package/templates/monorepo/auth/package.json +1 -1
- package/templates/monorepo/pnpm-workspace.yaml +8 -0
- package/templates/webapp/AGENTS.md +1 -1
- package/templates/webapp/README.md +2 -1
- package/templates/webapp/agent-skills/access-control.md +3 -3
- package/templates/webapp/agent-skills/database.md +2 -1
- package/templates/webapp/next.config.ts +1 -1
- package/templates/webapp/package.json.template +2 -2
- package/templates/webapp/scripts/seed.ts +3 -3
- package/templates/webapp/src/app/(settings)/settings/page.tsx +1 -1
- package/templates/webapp/src/drizzle/schema/index.ts +1 -1
- package/templates/webapp/src/lib/auth/index.ts +2 -2
- package/templates/webapp/src/startup-checks.ts +1 -1
- package/dist/register-app-mNc1oYVK.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -573,12 +573,14 @@ function getCompatibleTemplateVersion(manifest, templateType) {
|
|
|
573
573
|
//#endregion
|
|
574
574
|
//#region src/commands/create.ts
|
|
575
575
|
const PACKAGE_MANAGER = "pnpm";
|
|
576
|
-
const
|
|
577
|
-
const
|
|
576
|
+
const MAX_PACKAGE_MANAGER_OUTPUT_CHARS = 64e3;
|
|
577
|
+
const MAX_PACKAGE_MANAGER_OUTPUT_LINES = 80;
|
|
578
578
|
var PackageManagerCommandError = class extends Error {
|
|
579
|
+
command;
|
|
579
580
|
output;
|
|
580
|
-
constructor(message, output) {
|
|
581
|
+
constructor(message, command, output) {
|
|
581
582
|
super(message);
|
|
583
|
+
this.command = command;
|
|
582
584
|
this.output = output;
|
|
583
585
|
this.name = "PackageManagerCommandError";
|
|
584
586
|
}
|
|
@@ -587,13 +589,14 @@ var PackageManagerCommandError = class extends Error {
|
|
|
587
589
|
function shPath(p) {
|
|
588
590
|
return p.split(path.sep).join("/");
|
|
589
591
|
}
|
|
590
|
-
/** Non-blocking
|
|
591
|
-
function
|
|
592
|
+
/** Non-blocking package-manager command so ora can animate. */
|
|
593
|
+
function runPackageManagerCommand(packageManager, cwd, args) {
|
|
592
594
|
return new Promise((resolve, reject) => {
|
|
593
595
|
let output = "";
|
|
596
|
+
const command = `${packageManager} ${args.join(" ")}`;
|
|
594
597
|
const appendOutput = (chunk) => {
|
|
595
598
|
output += chunk.toString();
|
|
596
|
-
if (output.length >
|
|
599
|
+
if (output.length > MAX_PACKAGE_MANAGER_OUTPUT_CHARS) output = output.slice(-64e3);
|
|
597
600
|
};
|
|
598
601
|
const child = spawn(packageManager, args, {
|
|
599
602
|
cwd,
|
|
@@ -606,23 +609,27 @@ function runPackageManagerInstall(packageManager, cwd, args = ["install"]) {
|
|
|
606
609
|
child.stdout?.on("data", appendOutput);
|
|
607
610
|
child.stderr?.on("data", appendOutput);
|
|
608
611
|
child.on("error", (error) => {
|
|
609
|
-
reject(new PackageManagerCommandError(`${
|
|
612
|
+
reject(new PackageManagerCommandError(`${command} failed: ${error.message}`, command, output));
|
|
610
613
|
});
|
|
611
614
|
child.on("close", (code) => {
|
|
612
615
|
if (code === 0) resolve();
|
|
613
|
-
else reject(new PackageManagerCommandError(`${
|
|
616
|
+
else reject(new PackageManagerCommandError(`${command} exited with code ${code ?? "unknown"}`, command, output));
|
|
614
617
|
});
|
|
615
618
|
});
|
|
616
619
|
}
|
|
617
|
-
|
|
620
|
+
/** Non-blocking install so ora can animate (execSync would block timers). */
|
|
621
|
+
function runPackageManagerInstall(packageManager, cwd, args = ["install"]) {
|
|
622
|
+
return runPackageManagerCommand(packageManager, cwd, args);
|
|
623
|
+
}
|
|
624
|
+
function printPackageManagerFailureOutput(error) {
|
|
618
625
|
if (!(error instanceof PackageManagerCommandError)) return;
|
|
619
626
|
const output = error.output.trim();
|
|
620
627
|
if (!output) return;
|
|
621
628
|
const lines = output.split(/\r?\n/);
|
|
622
|
-
const omitted = Math.max(0, lines.length -
|
|
629
|
+
const omitted = Math.max(0, lines.length - MAX_PACKAGE_MANAGER_OUTPUT_LINES);
|
|
623
630
|
const visibleLines = lines.slice(-80);
|
|
624
631
|
console.log();
|
|
625
|
-
console.log(chalk.bold(`Last ${visibleLines.length} lines from
|
|
632
|
+
console.log(chalk.bold(`Last ${visibleLines.length} lines from ${error.command}:`));
|
|
626
633
|
if (omitted > 0) console.log(chalk.dim(`... omitted ${omitted} earlier lines ...`));
|
|
627
634
|
console.log(visibleLines.join("\n"));
|
|
628
635
|
}
|
|
@@ -880,7 +887,51 @@ async function installAtMonorepoRoot(monorepoRoot, installDeps) {
|
|
|
880
887
|
return true;
|
|
881
888
|
} catch (error) {
|
|
882
889
|
spinner.warn(`Failed to install dependencies. Run '${PACKAGE_MANAGER} install' from monorepo root.`);
|
|
883
|
-
|
|
890
|
+
printPackageManagerFailureOutput(error);
|
|
891
|
+
return false;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
async function collectGeneratedFormatTargets(args) {
|
|
895
|
+
const targets = [path.relative(args.monorepoRoot, args.packageDir) || "."];
|
|
896
|
+
if (args.projectType === "webapp") {
|
|
897
|
+
const workflowPath = path.join(args.monorepoRoot, ".github", "workflows", `${path.basename(args.packageDir)}-ryvn-release.yaml`);
|
|
898
|
+
if (await fs.pathExists(workflowPath)) targets.push(path.relative(args.monorepoRoot, workflowPath));
|
|
899
|
+
}
|
|
900
|
+
return targets.map(shPath);
|
|
901
|
+
}
|
|
902
|
+
async function runGeneratedProjectChecks(args) {
|
|
903
|
+
if (!args.installSucceeded) return false;
|
|
904
|
+
const formatArgs = args.scope === "workspace" || !args.packageDir ? ["run", "format"] : [
|
|
905
|
+
"exec",
|
|
906
|
+
"oxfmt",
|
|
907
|
+
...await collectGeneratedFormatTargets({
|
|
908
|
+
monorepoRoot: args.monorepoRoot,
|
|
909
|
+
packageDir: args.packageDir,
|
|
910
|
+
projectType: args.projectType
|
|
911
|
+
})
|
|
912
|
+
];
|
|
913
|
+
const lintArgs = args.scope === "workspace" || !args.packageDir ? ["run", "lint"] : [
|
|
914
|
+
"exec",
|
|
915
|
+
"oxlint",
|
|
916
|
+
shPath(path.relative(args.monorepoRoot, args.packageDir) || ".")
|
|
917
|
+
];
|
|
918
|
+
const formatSpinner = ora("Formatting generated files...").start();
|
|
919
|
+
try {
|
|
920
|
+
await runPackageManagerCommand(PACKAGE_MANAGER, args.monorepoRoot, formatArgs);
|
|
921
|
+
formatSpinner.succeed("Formatted generated files");
|
|
922
|
+
} catch (error) {
|
|
923
|
+
formatSpinner.warn("Generated formatting failed");
|
|
924
|
+
printPackageManagerFailureOutput(error);
|
|
925
|
+
return false;
|
|
926
|
+
}
|
|
927
|
+
const lintSpinner = ora("Linting generated files...").start();
|
|
928
|
+
try {
|
|
929
|
+
await runPackageManagerCommand(PACKAGE_MANAGER, args.monorepoRoot, lintArgs);
|
|
930
|
+
lintSpinner.succeed("Linted generated files");
|
|
931
|
+
return true;
|
|
932
|
+
} catch (error) {
|
|
933
|
+
lintSpinner.warn("Generated lint failed");
|
|
934
|
+
printPackageManagerFailureOutput(error);
|
|
884
935
|
return false;
|
|
885
936
|
}
|
|
886
937
|
}
|
|
@@ -1068,10 +1119,17 @@ async function createProject(options) {
|
|
|
1068
1119
|
});
|
|
1069
1120
|
await warnIfMissingRootNpmrc(monorepoRoot);
|
|
1070
1121
|
const installSucceeded = await installAtMonorepoRoot(monorepoRoot, answers.installDeps);
|
|
1122
|
+
const checksSucceeded = await runGeneratedProjectChecks({
|
|
1123
|
+
monorepoRoot,
|
|
1124
|
+
packageDir,
|
|
1125
|
+
projectType: answers.projectType,
|
|
1126
|
+
scope: "generated-package",
|
|
1127
|
+
installSucceeded
|
|
1128
|
+
});
|
|
1071
1129
|
console.log();
|
|
1072
1130
|
console.log(chalk.green("✔"), chalk.bold(`Created ${typeLabel} at`), chalk.cyan(path.relative(monorepoRoot, packageDir)));
|
|
1073
1131
|
console.log();
|
|
1074
|
-
if (await maybeAutoRunWebapp(packageDir, monorepoRoot, answers.projectType, installSucceeded)) return;
|
|
1132
|
+
if (await maybeAutoRunWebapp(packageDir, monorepoRoot, answers.projectType, installSucceeded && checksSucceeded)) return;
|
|
1075
1133
|
printNextStepsExisting(answers, packageDir, !installSucceeded);
|
|
1076
1134
|
} else {
|
|
1077
1135
|
const isBareMonorepo = answers.projectType === "monorepo";
|
|
@@ -1115,12 +1173,19 @@ async function createProject(options) {
|
|
|
1115
1173
|
templateCommit: getTemplateCommitSource(newWorkspaceManifest)
|
|
1116
1174
|
});
|
|
1117
1175
|
const installSucceeded = await installAtMonorepoRoot(monorepoRoot, answers.installDeps);
|
|
1176
|
+
const checksSucceeded = await runGeneratedProjectChecks({
|
|
1177
|
+
monorepoRoot,
|
|
1178
|
+
packageDir,
|
|
1179
|
+
projectType: answers.projectType,
|
|
1180
|
+
scope: "workspace",
|
|
1181
|
+
installSucceeded
|
|
1182
|
+
});
|
|
1118
1183
|
initGitRepo(monorepoRoot);
|
|
1119
1184
|
console.log();
|
|
1120
1185
|
console.log(chalk.green("✔"), chalk.bold(isBareMonorepo ? `Created ${typeLabel} at` : "Created monorepo at"), chalk.cyan(monorepoRoot));
|
|
1121
1186
|
if (!isBareMonorepo) console.log(chalk.green("✔"), chalk.bold(`Created ${typeLabel} at`), chalk.cyan(`packages/${answers.name}/`));
|
|
1122
1187
|
console.log();
|
|
1123
|
-
if (await maybeAutoRunWebapp(packageDir, monorepoRoot, answers.projectType, installSucceeded)) return;
|
|
1188
|
+
if (await maybeAutoRunWebapp(packageDir, monorepoRoot, answers.projectType, installSucceeded && checksSucceeded)) return;
|
|
1124
1189
|
printNextStepsNew(answers, monorepoRoot, !installSucceeded);
|
|
1125
1190
|
}
|
|
1126
1191
|
}
|
|
@@ -1303,7 +1368,7 @@ infra.command("register-os-blueprint").description("Register this customer monor
|
|
|
1303
1368
|
await registerOsBlueprintCommand();
|
|
1304
1369
|
});
|
|
1305
1370
|
infra.command("register-app").description("Register a webapp database in this customer OS blueprint").argument("<app>", "Webapp package name").action(async (appName) => {
|
|
1306
|
-
const { registerAppCommand } = await import("./register-app-
|
|
1371
|
+
const { registerAppCommand } = await import("./register-app-B9vKTkoI.js");
|
|
1307
1372
|
await registerAppCommand(appName);
|
|
1308
1373
|
});
|
|
1309
1374
|
program.command("status").description("Show template sync status for current app").option("--mosaic-template-path <path>", "Path to local mosaic repo checkout").action(async (options) => {
|