@theholocron/cli 4.16.3 → 4.16.5
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/cli.mjs +21 -17
- package/dist/cli.mjs.map +1 -1
- package/package.json +4 -4
package/dist/cli.mjs
CHANGED
|
@@ -1340,10 +1340,11 @@ function parseTopics(raw) {
|
|
|
1340
1340
|
function generateHolocronConfig(opts) {
|
|
1341
1341
|
const lines = [
|
|
1342
1342
|
`import { defineConfig } from "@theholocron/cli";`,
|
|
1343
|
-
`import { node } from "@theholocron/holocron-config";`,
|
|
1343
|
+
`import { compose, node, typecheck } from "@theholocron/holocron-config";`,
|
|
1344
1344
|
``,
|
|
1345
|
-
`const
|
|
1346
|
-
`export default defineConfig({
|
|
1345
|
+
`const preset = compose(node(), typecheck());`,
|
|
1346
|
+
`export default defineConfig({`,
|
|
1347
|
+
`\t...preset,`
|
|
1347
1348
|
];
|
|
1348
1349
|
if (opts.description) lines.push(`\tdescription: ${JSON.stringify(opts.description)},`);
|
|
1349
1350
|
if (opts.homepage) lines.push(`\thomepage: ${JSON.stringify(opts.homepage)},`);
|
|
@@ -1352,30 +1353,29 @@ function generateHolocronConfig(opts) {
|
|
|
1352
1353
|
if (opts.org != null) {
|
|
1353
1354
|
const repoName = `${opts.org}/${opts.name}`;
|
|
1354
1355
|
lines.push(`\trepo: {`);
|
|
1356
|
+
lines.push(`\t\t...preset.repo,`);
|
|
1355
1357
|
lines.push(`\t\tname: ${JSON.stringify(repoName)},`);
|
|
1356
1358
|
lines.push(`\t\tteams: [{ slug: "gatekeepers", permission: "maintain" }],`);
|
|
1357
1359
|
lines.push(`\t\ttopics: ${JSON.stringify(topics)},`);
|
|
1358
|
-
lines.push(`\t\t...repo,`);
|
|
1359
1360
|
if (opts.protection && opts.protection !== "strict") lines.push(`\t\tprotection: ${JSON.stringify(opts.protection)},`);
|
|
1360
1361
|
const propParts = [];
|
|
1361
1362
|
if (hasRuntimeOverride) propParts.push(`runtime_environment: ${JSON.stringify(opts.runtimeEnvironment)}`);
|
|
1362
1363
|
if (opts.openSource === false) propParts.push(`open_source: false`);
|
|
1363
1364
|
if (opts.usesExternalPackages === false) propParts.push(`uses_external_packages: false`);
|
|
1364
|
-
if (propParts.length > 0) lines.push(`\t\tproperties: { ...repo
|
|
1365
|
+
if (propParts.length > 0) lines.push(`\t\tproperties: { ...preset.repo?.properties, ${propParts.join(", ")} },`);
|
|
1365
1366
|
lines.push(`\t},`);
|
|
1366
1367
|
} else if (topics.length > 0 || hasRuntimeOverride) {
|
|
1367
1368
|
lines.push(`\trepo: {`);
|
|
1369
|
+
lines.push(`\t\t...preset.repo,`);
|
|
1368
1370
|
if (topics.length > 0) lines.push(`\t\ttopics: ${JSON.stringify(topics)},`);
|
|
1369
|
-
lines.push(`\t\
|
|
1370
|
-
if (hasRuntimeOverride) lines.push(`\t\tproperties: { ...repo.properties, runtime_environment: ${JSON.stringify(opts.runtimeEnvironment)} },`);
|
|
1371
|
+
if (hasRuntimeOverride) lines.push(`\t\tproperties: { ...preset.repo?.properties, runtime_environment: ${JSON.stringify(opts.runtimeEnvironment)} },`);
|
|
1371
1372
|
lines.push(`\t},`);
|
|
1372
|
-
}
|
|
1373
|
-
lines.push(`\tworkflows,`);
|
|
1373
|
+
}
|
|
1374
1374
|
const hasVault = opts.vaultProvider && opts.vaultProvider !== "none";
|
|
1375
1375
|
const hasDeployment = opts.deploymentProvider && opts.deploymentProvider !== "none";
|
|
1376
1376
|
if (hasVault || hasDeployment) {
|
|
1377
1377
|
lines.push(`\tproviders: {`);
|
|
1378
|
-
lines.push(`\t\t...providers,`);
|
|
1378
|
+
lines.push(`\t\t...preset.providers,`);
|
|
1379
1379
|
if (opts.vaultProvider === "doppler") {
|
|
1380
1380
|
const proj = JSON.stringify(opts.vaultProject ?? opts.name);
|
|
1381
1381
|
const cfg = JSON.stringify(opts.vaultConfig ?? "dev");
|
|
@@ -1389,7 +1389,7 @@ function generateHolocronConfig(opts) {
|
|
|
1389
1389
|
}
|
|
1390
1390
|
if (opts.deploymentProvider === "vercel") lines.push(`\t\tdeployment: "vercel",`);
|
|
1391
1391
|
lines.push(`\t},`);
|
|
1392
|
-
}
|
|
1392
|
+
}
|
|
1393
1393
|
if (opts.agent && opts.agent !== "none") lines.push(`\tagent: ${JSON.stringify(opts.agent)},`);
|
|
1394
1394
|
if (opts.skills?.length) lines.push(`\tskills: ${JSON.stringify(opts.skills)},`);
|
|
1395
1395
|
lines.push(`});`);
|
|
@@ -4512,7 +4512,7 @@ async function runSetup(input) {
|
|
|
4512
4512
|
print(formatStep(steps[steps.length - 1]));
|
|
4513
4513
|
if (config.syncScripts !== false) {
|
|
4514
4514
|
steps.push(await runStep("source", "set package.json prepare script", dryRun, async () => {
|
|
4515
|
-
return await ensurePrepareScript(input.context.repoRoot) ? "prepare
|
|
4515
|
+
return await ensurePrepareScript(input.context.repoRoot) ? "prepare now runs husky" : "already runs husky";
|
|
4516
4516
|
}));
|
|
4517
4517
|
print(formatStep(steps[steps.length - 1]));
|
|
4518
4518
|
}
|
|
@@ -4911,9 +4911,12 @@ async function runSetup(input) {
|
|
|
4911
4911
|
};
|
|
4912
4912
|
}
|
|
4913
4913
|
/**
|
|
4914
|
-
* Ensure `package.json#scripts.prepare`
|
|
4915
|
-
* install. Merge-only:
|
|
4916
|
-
*
|
|
4914
|
+
* Ensure `package.json#scripts.prepare` runs `husky` so git hooks register on
|
|
4915
|
+
* install. Merge-only: an existing `prepare` that does more than husky (e.g.
|
|
4916
|
+
* `turbo run build` — needed where root config files import a workspace
|
|
4917
|
+
* package's `dist/`, theholocron/holocron#654) is preserved and husky is
|
|
4918
|
+
* appended. Leaves every other script untouched. Returns `true` when it wrote
|
|
4919
|
+
* a change, `false` when already runs husky or there is no `package.json`.
|
|
4917
4920
|
*/
|
|
4918
4921
|
async function ensurePrepareScript(repoRoot) {
|
|
4919
4922
|
const pkgPath = join(repoRoot, "package.json");
|
|
@@ -4925,8 +4928,9 @@ async function ensurePrepareScript(repoRoot) {
|
|
|
4925
4928
|
}
|
|
4926
4929
|
const pkg = JSON.parse(content);
|
|
4927
4930
|
const scripts = pkg.scripts ?? {};
|
|
4928
|
-
|
|
4929
|
-
|
|
4931
|
+
const current = scripts.prepare?.trim() ?? "";
|
|
4932
|
+
if (/(^|[\s&|;])husky($|[\s&|;])/.test(current)) return false;
|
|
4933
|
+
scripts.prepare = current ? `${current} && husky` : "husky";
|
|
4930
4934
|
pkg.scripts = scripts;
|
|
4931
4935
|
await writeFile(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf8");
|
|
4932
4936
|
return true;
|