@theholocron/cli 5.5.0 → 5.5.1
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 +67 -32
- package/dist/cli.mjs.map +1 -1
- package/package.json +5 -5
package/dist/cli.mjs
CHANGED
|
@@ -34452,6 +34452,36 @@ const secretSetCommand = {
|
|
|
34452
34452
|
})).status === "fail") process.exitCode = 1;
|
|
34453
34453
|
}
|
|
34454
34454
|
};
|
|
34455
|
+
// src/commands/new/without-tokens/without-tokens.ts
|
|
34456
|
+
/** The names of variables that hold a credential for GitHub, this CLI or 1Password. */
|
|
34457
|
+
const CREDENTIAL_NAME = /^(HOLOCRON|GITHUB|GH|OP)_.*(TOKEN|SECRET|KEY)$/;
|
|
34458
|
+
/**
|
|
34459
|
+
* A copy of `env` without the variables that hold a credential for GitHub (`GITHUB_TOKEN`, `GH_TOKEN`), this CLI
|
|
34460
|
+
* (`HOLOCRON_*_TOKEN`) or 1Password (`OP_SERVICE_ACCOUNT_TOKEN`): names that start with one of those prefixes and end in
|
|
34461
|
+
* `TOKEN`, `SECRET` or `KEY`. Everything else (`PATH`, `HOME`, proxy and registry settings) stays, so a program started
|
|
34462
|
+
* with it still finds its tools.
|
|
34463
|
+
*/
|
|
34464
|
+
function withoutTokens(env) {
|
|
34465
|
+
return Object.fromEntries(Object.entries(env).filter(([name]) => !CREDENTIAL_NAME.test(name)));
|
|
34466
|
+
}
|
|
34467
|
+
// src/commands/new/default-exec/default-exec.ts
|
|
34468
|
+
/**
|
|
34469
|
+
* Runs `cmd` with `args` in `opts.cwd`, printing to this terminal. `opts.env` is added to this process's environment;
|
|
34470
|
+
* with `opts.cleanEnv` the credential variables are removed from it first (`withoutTokens()`), for a step that runs code
|
|
34471
|
+
* the person did not write, such as the lifecycle scripts of a package install.
|
|
34472
|
+
*/
|
|
34473
|
+
function defaultExec$1(cmd, args, opts) {
|
|
34474
|
+
const extra = opts.env ?? {};
|
|
34475
|
+
const needsEnv = opts.cleanEnv === true || Object.keys(extra).length > 0;
|
|
34476
|
+
execFileSync(cmd, args, {
|
|
34477
|
+
cwd: opts.cwd,
|
|
34478
|
+
stdio: opts.stdio,
|
|
34479
|
+
...needsEnv ? { env: {
|
|
34480
|
+
...opts.cleanEnv ? withoutTokens(process.env) : process.env,
|
|
34481
|
+
...extra
|
|
34482
|
+
} } : {}
|
|
34483
|
+
});
|
|
34484
|
+
}
|
|
34455
34485
|
// src/commands/new/new.ts
|
|
34456
34486
|
/**
|
|
34457
34487
|
* `holocron new repo <type> <name>` — create a GitHub repo from a template and
|
|
@@ -34621,16 +34651,6 @@ function preflight() {
|
|
|
34621
34651
|
const result = spawnSync("gh", ["--version"], { encoding: "utf8" });
|
|
34622
34652
|
if (result.error != null || result.status !== 0) throw new NewError("`gh` CLI is not installed or not on PATH. Install it from https://cli.github.com");
|
|
34623
34653
|
}
|
|
34624
|
-
function defaultExec$1(cmd, args, opts) {
|
|
34625
|
-
execFileSync(cmd, args, {
|
|
34626
|
-
cwd: opts.cwd,
|
|
34627
|
-
stdio: opts.stdio,
|
|
34628
|
-
...opts.env && Object.keys(opts.env).length > 0 ? { env: {
|
|
34629
|
-
...process.env,
|
|
34630
|
-
...opts.env
|
|
34631
|
-
} } : {}
|
|
34632
|
-
});
|
|
34633
|
-
}
|
|
34634
34654
|
function keychainLookup(key) {
|
|
34635
34655
|
const result = spawnSync("security", [
|
|
34636
34656
|
"find-generic-password",
|
|
@@ -34725,6 +34745,16 @@ async function runNew(input) {
|
|
|
34725
34745
|
} catch {}
|
|
34726
34746
|
let templateSlug = `${input.type}-template`;
|
|
34727
34747
|
const pkgJsonPath = path.join(repoDir, "package.json");
|
|
34748
|
+
const canRead = (file) => {
|
|
34749
|
+
try {
|
|
34750
|
+
readFn(file);
|
|
34751
|
+
return true;
|
|
34752
|
+
} catch {
|
|
34753
|
+
return false;
|
|
34754
|
+
}
|
|
34755
|
+
};
|
|
34756
|
+
const hasPackageJson = canRead(pkgJsonPath);
|
|
34757
|
+
const hasJsonConfig = canRead(path.join(repoDir, "holocron.config.json"));
|
|
34728
34758
|
if (existsSync(pkgJsonPath)) try {
|
|
34729
34759
|
const pkg = JSON.parse(readFn(pkgJsonPath));
|
|
34730
34760
|
if (typeof pkg.name === "string") templateSlug = pkg.name.split("/").at(-1) || templateSlug;
|
|
@@ -34754,26 +34784,29 @@ async function runNew(input) {
|
|
|
34754
34784
|
print(` ✓ tsconfig.json (display)`);
|
|
34755
34785
|
}
|
|
34756
34786
|
} catch {}
|
|
34757
|
-
|
|
34758
|
-
|
|
34759
|
-
|
|
34760
|
-
|
|
34761
|
-
|
|
34762
|
-
|
|
34763
|
-
|
|
34764
|
-
|
|
34765
|
-
|
|
34766
|
-
|
|
34767
|
-
|
|
34768
|
-
|
|
34769
|
-
|
|
34770
|
-
|
|
34771
|
-
|
|
34772
|
-
|
|
34773
|
-
|
|
34774
|
-
|
|
34775
|
-
|
|
34776
|
-
|
|
34787
|
+
if (hasJsonConfig) print(` Kept holocron.config.json`);
|
|
34788
|
+
else {
|
|
34789
|
+
const configContent = generateHolocronConfig({
|
|
34790
|
+
name: input.name,
|
|
34791
|
+
type: input.type,
|
|
34792
|
+
org,
|
|
34793
|
+
description: input.description,
|
|
34794
|
+
homepage: input.homepage,
|
|
34795
|
+
vaultProvider: input.vaultProvider,
|
|
34796
|
+
vaultProject: input.vaultProject,
|
|
34797
|
+
vaultConfig: input.vaultConfig,
|
|
34798
|
+
deploymentProvider: input.deploymentProvider,
|
|
34799
|
+
agent: input.agent,
|
|
34800
|
+
runtimeEnvironment: input.runtimeEnvironment,
|
|
34801
|
+
protection: input.protection,
|
|
34802
|
+
openSource: input.openSource,
|
|
34803
|
+
usesExternalPackages: input.usesExternalPackages,
|
|
34804
|
+
topics: input.topics,
|
|
34805
|
+
skills: input.skills
|
|
34806
|
+
});
|
|
34807
|
+
writeFn(path.join(repoDir, "holocron.config.ts"), configContent);
|
|
34808
|
+
print(` Generated holocron.config.ts`);
|
|
34809
|
+
}
|
|
34777
34810
|
execFn("git", ["add", "-A"], {
|
|
34778
34811
|
cwd: repoDir,
|
|
34779
34812
|
stdio: "inherit"
|
|
@@ -34790,10 +34823,12 @@ async function runNew(input) {
|
|
|
34790
34823
|
if (!input.noVerify) {
|
|
34791
34824
|
print("");
|
|
34792
34825
|
print(" Installing dependencies…");
|
|
34793
|
-
|
|
34826
|
+
if (!hasPackageJson) print(" No package.json: skipping pnpm install");
|
|
34827
|
+
else try {
|
|
34794
34828
|
execFn("pnpm", ["install"], {
|
|
34795
34829
|
cwd: repoDir,
|
|
34796
|
-
stdio: "inherit"
|
|
34830
|
+
stdio: "inherit",
|
|
34831
|
+
cleanEnv: true
|
|
34797
34832
|
});
|
|
34798
34833
|
} catch (err) {
|
|
34799
34834
|
print(` ✗ pnpm install failed — ${errorMessage(err)}`);
|