@penvhq/cli 0.9.5 → 0.10.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/dist/bin.cjs +429 -62
- package/dist/bin.cjs.map +1 -1
- package/dist/index.cjs +73 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +118 -64
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -326,7 +326,7 @@ function installFailed(plan2) {
|
|
|
326
326
|
|
|
327
327
|
// src/project.ts
|
|
328
328
|
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
329
|
-
import { dirname, join as
|
|
329
|
+
import { dirname, join as join4 } from "path";
|
|
330
330
|
import {
|
|
331
331
|
assertMigrated,
|
|
332
332
|
candidatesFor,
|
|
@@ -408,15 +408,20 @@ function environmentFromShorthand(config, candidates, explicit) {
|
|
|
408
408
|
// src/registry.ts
|
|
409
409
|
import { readFileSync as readFileSync2 } from "fs";
|
|
410
410
|
import { createRequire } from "module";
|
|
411
|
-
import { resolve } from "path";
|
|
411
|
+
import { join as join3, resolve } from "path";
|
|
412
412
|
import { pathToFileURL } from "url";
|
|
413
413
|
import {
|
|
414
414
|
holdsProjection,
|
|
415
415
|
LOCAL_EXTENSIONS_PATH,
|
|
416
416
|
localExtensionsFile,
|
|
417
|
+
MANIFEST_PATH,
|
|
417
418
|
PENV_DIR,
|
|
418
419
|
PenvError as PenvError4,
|
|
420
|
+
packageDir,
|
|
421
|
+
packageEntry,
|
|
419
422
|
parseLocalExtensions,
|
|
423
|
+
parseManifest,
|
|
424
|
+
penvHome,
|
|
420
425
|
recordsDir
|
|
421
426
|
} from "@penvhq/core";
|
|
422
427
|
import { createFilesystemProvider } from "@penvhq/provider-filesystem";
|
|
@@ -461,19 +466,12 @@ async function createSourceProvider(type, context) {
|
|
|
461
466
|
return loadPluginProvider(type, context);
|
|
462
467
|
}
|
|
463
468
|
async function loadPluginProvider(type, context) {
|
|
464
|
-
const
|
|
465
|
-
if (resolved === void 0) {
|
|
466
|
-
throw unknownProvider(type, context.environment);
|
|
467
|
-
}
|
|
469
|
+
const path = resolveExtension(type, context.root, context.environment);
|
|
468
470
|
let mod;
|
|
469
471
|
try {
|
|
470
|
-
mod = await importPlugin(
|
|
471
|
-
} catch {
|
|
472
|
-
throw
|
|
473
|
-
"PROVIDER_PLUGIN_LOAD",
|
|
474
|
-
`The provider package \`${type}\` failed to load`,
|
|
475
|
-
"It resolved but threw while importing. Check it builds and its dependencies are installed."
|
|
476
|
-
);
|
|
472
|
+
mod = await importPlugin(path);
|
|
473
|
+
} catch (cause) {
|
|
474
|
+
throw providerLoadFailed(type, path, cause);
|
|
477
475
|
}
|
|
478
476
|
const factory = mod[PLUGIN_FACTORY_EXPORT];
|
|
479
477
|
if (typeof factory !== "function") {
|
|
@@ -497,10 +495,42 @@ function assertProvidersRegistered(config, projectRoot, options) {
|
|
|
497
495
|
if (ci && local.includes(provider.type)) {
|
|
498
496
|
throw localExtensionInCi(provider.type, environment);
|
|
499
497
|
}
|
|
500
|
-
|
|
501
|
-
|
|
498
|
+
resolveExtension(provider.type, projectRoot, environment, local);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
function resolveExtension(type, projectRoot, environment, local = localExtensions(projectRoot)) {
|
|
502
|
+
const fromProject = resolvePlugin(type, projectRoot);
|
|
503
|
+
if (local.includes(type)) {
|
|
504
|
+
if (fromProject === void 0) {
|
|
505
|
+
throw localExtensionUnresolved(type, projectRoot, environment);
|
|
502
506
|
}
|
|
507
|
+
return fromProject;
|
|
508
|
+
}
|
|
509
|
+
if (fromProject !== void 0) {
|
|
510
|
+
return fromProject;
|
|
503
511
|
}
|
|
512
|
+
const version = pinnedVersion(type, projectRoot);
|
|
513
|
+
if (version === void 0) {
|
|
514
|
+
throw unknownProvider(type, environment);
|
|
515
|
+
}
|
|
516
|
+
const stored = storedExtension(type, version);
|
|
517
|
+
if (stored === void 0) {
|
|
518
|
+
throw extensionNotInstalled(type, version, environment);
|
|
519
|
+
}
|
|
520
|
+
return stored;
|
|
521
|
+
}
|
|
522
|
+
function pinnedVersion(type, projectRoot) {
|
|
523
|
+
let manifest;
|
|
524
|
+
try {
|
|
525
|
+
manifest = parseManifest(readFileSync2(join3(projectRoot, ...MANIFEST_PATH.split("/")), "utf8"));
|
|
526
|
+
} catch {
|
|
527
|
+
return void 0;
|
|
528
|
+
}
|
|
529
|
+
return manifest.extensions[type]?.version;
|
|
530
|
+
}
|
|
531
|
+
function storedExtension(type, version) {
|
|
532
|
+
const entry = packageEntry(packageDir(penvHome(process.env), "extensions", type, version));
|
|
533
|
+
return entry?.file;
|
|
504
534
|
}
|
|
505
535
|
function localExtensions(projectRoot) {
|
|
506
536
|
let text;
|
|
@@ -552,13 +582,37 @@ function assertSatisfiesContract(provider, specifier) {
|
|
|
552
582
|
}
|
|
553
583
|
}
|
|
554
584
|
}
|
|
585
|
+
function where(environment) {
|
|
586
|
+
return environment === void 0 ? "" : ` for environment ${environment}`;
|
|
587
|
+
}
|
|
555
588
|
function unknownProvider(type, environment) {
|
|
556
589
|
const preinstalled = [...REGISTRY.keys()].map((name) => `\`${name}\``).join(", ");
|
|
557
|
-
const where = environment === void 0 ? "" : ` for environment ${environment}`;
|
|
558
590
|
return new PenvError4(
|
|
559
591
|
"UNKNOWN_PROVIDER",
|
|
560
|
-
`The provider \`${type}\`${where} in penv.config.ts is
|
|
561
|
-
`
|
|
592
|
+
`The provider \`${type}\`${where(environment)} in penv.config.ts is nowhere penv looks for it`,
|
|
593
|
+
`Run \`penv add ${type}\` to pin a release, or \`penv add --local ${type}\` if this repository is the one that builds it. penv looks in ${LOCAL_EXTENSIONS_PATH}, this project's node_modules, and then $PENV_HOME at the version ${MANIFEST_PATH} pins. The CLI ships ${preinstalled} pre-installed.`
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
function extensionNotInstalled(type, version, environment) {
|
|
597
|
+
return new PenvError4(
|
|
598
|
+
"EXTENSION_NOT_INSTALLED",
|
|
599
|
+
`${MANIFEST_PATH} pins \`${type}\` ${version}${where(environment)}, and it is not installed in ${penvHome(process.env)}`,
|
|
600
|
+
"Run `penv install` \u2014 it downloads and verifies every version the manifest pins, extensions included."
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
function localExtensionUnresolved(type, projectRoot, environment) {
|
|
604
|
+
return new PenvError4(
|
|
605
|
+
"LOCAL_EXTENSION_UNRESOLVED",
|
|
606
|
+
`${LOCAL_EXTENSIONS_PATH} records \`${type}\`${where(environment)} as a package this project develops, and it does not resolve from ${projectRoot}`,
|
|
607
|
+
`Add it as a dependency of the root (a workspace link is one) and run \`pnpm install\`, or drop the name from ${LOCAL_EXTENSIONS_PATH} if this project no longer builds it.`
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
function providerLoadFailed(type, path, cause) {
|
|
611
|
+
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
612
|
+
return new PenvError4(
|
|
613
|
+
"PROVIDER_PLUGIN_LOAD",
|
|
614
|
+
`The provider package \`${type}\` failed to load from ${path}: ${detail}`,
|
|
615
|
+
"penv imports that file exactly as it stands, with no transform, so it has to be built JavaScript with its dependencies installed."
|
|
562
616
|
);
|
|
563
617
|
}
|
|
564
618
|
|
|
@@ -587,7 +641,7 @@ function localTree(project) {
|
|
|
587
641
|
return project.provider;
|
|
588
642
|
}
|
|
589
643
|
function selfContainedSchemaModule(root, schemaFile) {
|
|
590
|
-
const file =
|
|
644
|
+
const file = join4(root, ...schemaFile.split("/"));
|
|
591
645
|
if (!existsSync3(file)) {
|
|
592
646
|
return void 0;
|
|
593
647
|
}
|
|
@@ -859,7 +913,7 @@ async function guard(run) {
|
|
|
859
913
|
// src/commands/run.ts
|
|
860
914
|
import { existsSync as existsSync4, readFileSync as readFileSync4, watch } from "fs";
|
|
861
915
|
import { createRequire as createRequire2 } from "module";
|
|
862
|
-
import { basename, dirname as dirname2, join as
|
|
916
|
+
import { basename, dirname as dirname2, join as join5, resolve as resolve2 } from "path";
|
|
863
917
|
import {
|
|
864
918
|
ARTIFACT_BUILD_COMMAND,
|
|
865
919
|
assertArtifactFor,
|
|
@@ -1699,7 +1753,7 @@ function packageManifest(specifier, root) {
|
|
|
1699
1753
|
return void 0;
|
|
1700
1754
|
}
|
|
1701
1755
|
for (; ; ) {
|
|
1702
|
-
const file =
|
|
1756
|
+
const file = join5(directory, "package.json");
|
|
1703
1757
|
if (existsSync4(file)) {
|
|
1704
1758
|
try {
|
|
1705
1759
|
const parsed = JSON.parse(readFileSync4(file, "utf8"));
|
|
@@ -2201,7 +2255,7 @@ import {
|
|
|
2201
2255
|
rmSync,
|
|
2202
2256
|
writeFileSync as writeFileSync2
|
|
2203
2257
|
} from "fs";
|
|
2204
|
-
import { dirname as dirname4, join as
|
|
2258
|
+
import { dirname as dirname4, join as join6, resolve as resolve4 } from "path";
|
|
2205
2259
|
import {
|
|
2206
2260
|
CUTOVER_PATH,
|
|
2207
2261
|
findConfigFile,
|
|
@@ -2211,7 +2265,7 @@ import {
|
|
|
2211
2265
|
} from "@penvhq/core";
|
|
2212
2266
|
var CUTOVER_FORMAT = 1;
|
|
2213
2267
|
function fileFor(root, relativePosix) {
|
|
2214
|
-
return
|
|
2268
|
+
return join6(root, ...relativePosix.split("/"));
|
|
2215
2269
|
}
|
|
2216
2270
|
function bundleDir(root) {
|
|
2217
2271
|
return fileFor(root, ROLLBACK_DOTENV_PATH);
|
|
@@ -2298,7 +2352,7 @@ function bundleDotenvFiles(root, files, environments, now = /* @__PURE__ */ new
|
|
|
2298
2352
|
const bundle = bundleDir(root);
|
|
2299
2353
|
mkdirSync2(bundle, { recursive: true });
|
|
2300
2354
|
for (const name of files) {
|
|
2301
|
-
renameSync(
|
|
2355
|
+
renameSync(join6(root, name), join6(bundle, name));
|
|
2302
2356
|
}
|
|
2303
2357
|
return cutover;
|
|
2304
2358
|
}
|
|
@@ -2317,7 +2371,7 @@ function runUndo(options) {
|
|
|
2317
2371
|
const names = [...recorded, ...bundled.filter((name) => !recorded.includes(name))];
|
|
2318
2372
|
const bundle = bundleDir(root);
|
|
2319
2373
|
const held = new Set(bundled);
|
|
2320
|
-
const occupied2 = names.filter((name) => held.has(name) && existsSync5(
|
|
2374
|
+
const occupied2 = names.filter((name) => held.has(name) && existsSync5(join6(root, name)));
|
|
2321
2375
|
if (occupied2.length > 0) {
|
|
2322
2376
|
const listed = occupied2.join(", ");
|
|
2323
2377
|
const many = occupied2.length > 1;
|
|
@@ -2332,9 +2386,9 @@ function runUndo(options) {
|
|
|
2332
2386
|
const missing = [];
|
|
2333
2387
|
for (const name of names) {
|
|
2334
2388
|
if (held.has(name)) {
|
|
2335
|
-
renameSync(
|
|
2389
|
+
renameSync(join6(bundle, name), join6(root, name));
|
|
2336
2390
|
restored.push(name);
|
|
2337
|
-
} else if (existsSync5(
|
|
2391
|
+
} else if (existsSync5(join6(root, name))) {
|
|
2338
2392
|
alreadyBack.push(name);
|
|
2339
2393
|
} else {
|
|
2340
2394
|
missing.push(name);
|
|
@@ -2388,7 +2442,7 @@ var cleanupCommand = defineCommand5({
|
|
|
2388
2442
|
|
|
2389
2443
|
// src/commands/doctor.ts
|
|
2390
2444
|
import { readdirSync as readdirSync3, readFileSync as readFileSync6, statSync as statSync2 } from "fs";
|
|
2391
|
-
import { join as
|
|
2445
|
+
import { join as join7, relative as relative2 } from "path";
|
|
2392
2446
|
import {
|
|
2393
2447
|
ARTIFACT_BUILD_COMMAND as ARTIFACT_BUILD_COMMAND2,
|
|
2394
2448
|
accessPath as accessPath3,
|
|
@@ -3342,7 +3396,7 @@ function scannableFiles(directory, out2) {
|
|
|
3342
3396
|
return;
|
|
3343
3397
|
}
|
|
3344
3398
|
for (const entry of entries) {
|
|
3345
|
-
const path =
|
|
3399
|
+
const path = join7(directory, entry.name);
|
|
3346
3400
|
if (entry.isDirectory()) {
|
|
3347
3401
|
if (!UNSCANNED_DIRS.has(entry.name)) {
|
|
3348
3402
|
scannableFiles(path, out2);
|
|
@@ -4397,9 +4451,9 @@ function assertImportable(ref, variable) {
|
|
|
4397
4451
|
`Filenames are split on \`.\`. Rename ${variable} in the source file, then import it again.`
|
|
4398
4452
|
);
|
|
4399
4453
|
}
|
|
4400
|
-
function assertNotReserved(ref, variable,
|
|
4454
|
+
function assertNotReserved(ref, variable, where2, config) {
|
|
4401
4455
|
if (isReservedToken3(ref.name, config)) {
|
|
4402
|
-
throw new ReservedTokenError3("parameter", variable,
|
|
4456
|
+
throw new ReservedTokenError3("parameter", variable, where2);
|
|
4403
4457
|
}
|
|
4404
4458
|
}
|
|
4405
4459
|
function assertRoundTrips(ref, variable, config) {
|
|
@@ -4416,12 +4470,12 @@ function assertRoundTrips(ref, variable, config) {
|
|
|
4416
4470
|
`\`penv generate\` would write ${generated}, so anything reading \`process.env["${variable}"]\` would read \`undefined\`. Declare the name you want in the \`override\` block of penv.config.ts \u2014 \`override: { "${ref.name}": "${variable}" }\` \u2014 then import it again. Nothing was imported.`
|
|
4417
4471
|
);
|
|
4418
4472
|
}
|
|
4419
|
-
function refsForEntries(entries,
|
|
4473
|
+
function refsForEntries(entries, where2, config) {
|
|
4420
4474
|
const refs = [];
|
|
4421
4475
|
for (const entry of entries) {
|
|
4422
4476
|
const ref = refFromVariable2(entry.key);
|
|
4423
4477
|
assertImportable(ref, entry.key);
|
|
4424
|
-
assertNotReserved(ref, entry.key,
|
|
4478
|
+
assertNotReserved(ref, entry.key, where2, config);
|
|
4425
4479
|
assertRoundTrips(ref, entry.key, config);
|
|
4426
4480
|
refs.push(ref);
|
|
4427
4481
|
}
|
|
@@ -4452,7 +4506,7 @@ function writeEntries(tree, entries, refs, scope) {
|
|
|
4452
4506
|
|
|
4453
4507
|
// src/detect.ts
|
|
4454
4508
|
import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
|
|
4455
|
-
import { join as
|
|
4509
|
+
import { join as join8 } from "path";
|
|
4456
4510
|
import { DEFAULT_SCHEMA_FILE } from "@penvhq/core";
|
|
4457
4511
|
var SIGNATURES = [
|
|
4458
4512
|
{ name: "Next.js", packages: ["next"], publicPrefixes: ["NEXT_PUBLIC_"] },
|
|
@@ -4480,7 +4534,7 @@ function exportsSchema(file) {
|
|
|
4480
4534
|
);
|
|
4481
4535
|
}
|
|
4482
4536
|
function occupied(cwd, relative5) {
|
|
4483
|
-
const file =
|
|
4537
|
+
const file = join8(cwd, ...relative5.split("/"));
|
|
4484
4538
|
return existsSync6(file) && !exportsSchema(file);
|
|
4485
4539
|
}
|
|
4486
4540
|
function schemaFileFor(cwd) {
|
|
@@ -4496,7 +4550,7 @@ function schemaFileFor(cwd) {
|
|
|
4496
4550
|
return { file: DEFAULT_SCHEMA_FILE, displaced: preferred };
|
|
4497
4551
|
}
|
|
4498
4552
|
function srcPrefix(cwd) {
|
|
4499
|
-
return existsSync6(
|
|
4553
|
+
return existsSync6(join8(cwd, "src")) ? "src/" : "";
|
|
4500
4554
|
}
|
|
4501
4555
|
function dependenciesOf(cwd) {
|
|
4502
4556
|
const manifest = manifestOf2(cwd);
|
|
@@ -4515,7 +4569,7 @@ function dependenciesOf(cwd) {
|
|
|
4515
4569
|
return names;
|
|
4516
4570
|
}
|
|
4517
4571
|
function manifestOf2(cwd) {
|
|
4518
|
-
const file =
|
|
4572
|
+
const file = join8(cwd, "package.json");
|
|
4519
4573
|
if (!existsSync6(file)) {
|
|
4520
4574
|
return void 0;
|
|
4521
4575
|
}
|
|
@@ -4537,7 +4591,7 @@ function detectFramework(cwd) {
|
|
|
4537
4591
|
return detectedFrom(cwd, signature.name, signature.publicPrefixes);
|
|
4538
4592
|
}
|
|
4539
4593
|
}
|
|
4540
|
-
if (existsSync6(
|
|
4594
|
+
if (existsSync6(join8(cwd, "bunfig.toml")) || dependencies.has("bun-types")) {
|
|
4541
4595
|
return detectedFrom(cwd, "Bun", []);
|
|
4542
4596
|
}
|
|
4543
4597
|
return void 0;
|
|
@@ -4617,7 +4671,7 @@ function draftFieldsAcross(sources, environments) {
|
|
|
4617
4671
|
|
|
4618
4672
|
// src/commands/init.ts
|
|
4619
4673
|
import { existsSync as existsSync8, mkdirSync as mkdirSync4, readdirSync as readdirSync5, readFileSync as readFileSync9, writeFileSync as writeFileSync5 } from "fs";
|
|
4620
|
-
import { dirname as dirname6, join as
|
|
4674
|
+
import { dirname as dirname6, join as join10, resolve as resolve6 } from "path";
|
|
4621
4675
|
import { createInterface as createInterface2 } from "readline/promises";
|
|
4622
4676
|
import {
|
|
4623
4677
|
CUTOVER_PATH as CUTOVER_PATH3,
|
|
@@ -4651,7 +4705,7 @@ import {
|
|
|
4651
4705
|
unlinkSync,
|
|
4652
4706
|
writeFileSync as writeFileSync4
|
|
4653
4707
|
} from "fs";
|
|
4654
|
-
import { dirname as dirname5, join as
|
|
4708
|
+
import { dirname as dirname5, join as join9 } from "path";
|
|
4655
4709
|
function record(path, files, dirs) {
|
|
4656
4710
|
let stats;
|
|
4657
4711
|
try {
|
|
@@ -4662,7 +4716,7 @@ function record(path, files, dirs) {
|
|
|
4662
4716
|
if (stats.isDirectory()) {
|
|
4663
4717
|
dirs.add(path);
|
|
4664
4718
|
for (const entry of readdirSync4(path)) {
|
|
4665
|
-
record(
|
|
4719
|
+
record(join9(path, entry), files, dirs);
|
|
4666
4720
|
}
|
|
4667
4721
|
return;
|
|
4668
4722
|
}
|
|
@@ -4712,7 +4766,7 @@ function removeAdded(path, undo) {
|
|
|
4712
4766
|
return;
|
|
4713
4767
|
}
|
|
4714
4768
|
for (const entry of readdirSync4(path)) {
|
|
4715
|
-
removeAdded(
|
|
4769
|
+
removeAdded(join9(path, entry), undo);
|
|
4716
4770
|
}
|
|
4717
4771
|
if (!undo.dirs.has(path) && readdirSync4(path).length === 0) {
|
|
4718
4772
|
rmdirSync(path);
|
|
@@ -4930,7 +4984,7 @@ function configOf(decisions) {
|
|
|
4930
4984
|
return { environments: decisions.environments, providers: {}, schemaFile: decisions.schemaFile };
|
|
4931
4985
|
}
|
|
4932
4986
|
function declaredIn(root) {
|
|
4933
|
-
const file =
|
|
4987
|
+
const file = join10(root, CONFIG_FILE);
|
|
4934
4988
|
if (!existsSync8(file)) {
|
|
4935
4989
|
return void 0;
|
|
4936
4990
|
}
|
|
@@ -5381,7 +5435,7 @@ function ensurePenvDir(root) {
|
|
|
5381
5435
|
return { target: "penv-dir", action: "created", text: `Created ${PENV_DIR2}/` };
|
|
5382
5436
|
}
|
|
5383
5437
|
function writeSchemaShapeFile(root, fields, draft, decisions = DEFAULT_DECISIONS) {
|
|
5384
|
-
const file =
|
|
5438
|
+
const file = join10(root, SCHEMA_SHAPE_FILE3);
|
|
5385
5439
|
if (existsSync8(file)) {
|
|
5386
5440
|
return {
|
|
5387
5441
|
target: "schema",
|
|
@@ -5408,7 +5462,7 @@ function writeSchemaShapeFile(root, fields, draft, decisions = DEFAULT_DECISIONS
|
|
|
5408
5462
|
};
|
|
5409
5463
|
}
|
|
5410
5464
|
function writeEnvFile(root, decisions = DEFAULT_DECISIONS) {
|
|
5411
|
-
const file =
|
|
5465
|
+
const file = join10(root, ...decisions.schemaFile.split("/"));
|
|
5412
5466
|
if (existsSync8(file)) {
|
|
5413
5467
|
return {
|
|
5414
5468
|
target: "env",
|
|
@@ -5427,7 +5481,7 @@ function writeEnvFile(root, decisions = DEFAULT_DECISIONS) {
|
|
|
5427
5481
|
};
|
|
5428
5482
|
}
|
|
5429
5483
|
function writeConfigFile(root, decisions = DEFAULT_DECISIONS) {
|
|
5430
|
-
const file =
|
|
5484
|
+
const file = join10(root, CONFIG_FILE);
|
|
5431
5485
|
if (existsSync8(file)) {
|
|
5432
5486
|
return { target: "config", action: "kept", text: `Kept ${CONFIG_FILE}` };
|
|
5433
5487
|
}
|
|
@@ -5437,8 +5491,8 @@ function writeConfigFile(root, decisions = DEFAULT_DECISIONS) {
|
|
|
5437
5491
|
function writeTsconfigAlias(root, decisions = DEFAULT_DECISIONS) {
|
|
5438
5492
|
const alias = decisions.alias;
|
|
5439
5493
|
const imports = alias.startsWith(IMPORTS_PREFIX);
|
|
5440
|
-
const file =
|
|
5441
|
-
const
|
|
5494
|
+
const file = join10(root, imports ? PACKAGE_FILE : TSCONFIG_FILE);
|
|
5495
|
+
const where2 = imports ? PACKAGE_FILE : TSCONFIG_FILE;
|
|
5442
5496
|
if (!existsSync8(file)) {
|
|
5443
5497
|
if (imports) {
|
|
5444
5498
|
return {
|
|
@@ -5461,7 +5515,7 @@ function writeTsconfigAlias(root, decisions = DEFAULT_DECISIONS) {
|
|
|
5461
5515
|
return {
|
|
5462
5516
|
target: "tsconfig",
|
|
5463
5517
|
action: "conflicted",
|
|
5464
|
-
text: `${
|
|
5518
|
+
text: `${where2} already maps ${alias} to ${edit.conflict}`,
|
|
5465
5519
|
note: `(left alone \u2014 \`import { env } from "${alias}"\` will not reach ${decisions.schemaFile})`
|
|
5466
5520
|
};
|
|
5467
5521
|
}
|
|
@@ -5469,18 +5523,18 @@ function writeTsconfigAlias(root, decisions = DEFAULT_DECISIONS) {
|
|
|
5469
5523
|
return {
|
|
5470
5524
|
target: "tsconfig",
|
|
5471
5525
|
action: "kept",
|
|
5472
|
-
text: `Kept the ${alias} alias in ${
|
|
5526
|
+
text: `Kept the ${alias} alias in ${where2}`
|
|
5473
5527
|
};
|
|
5474
5528
|
}
|
|
5475
5529
|
writeFileSync5(file, edit.source, "utf8");
|
|
5476
5530
|
return {
|
|
5477
5531
|
target: "tsconfig",
|
|
5478
5532
|
action: "updated",
|
|
5479
|
-
text: `Added ${alias} alias to ${
|
|
5533
|
+
text: `Added ${alias} alias to ${where2}`
|
|
5480
5534
|
};
|
|
5481
5535
|
}
|
|
5482
5536
|
function writeGitignore(root, decisions = DEFAULT_DECISIONS) {
|
|
5483
|
-
const file =
|
|
5537
|
+
const file = join10(root, ...STATE_GITIGNORE_PATH.split("/"));
|
|
5484
5538
|
const wanted = renderStateGitignore(configOf(decisions));
|
|
5485
5539
|
const existing = existsSync8(file) ? readFileSync9(file, "utf8") : void 0;
|
|
5486
5540
|
if (existing === wanted) {
|
|
@@ -5503,7 +5557,7 @@ function outdatedRuntimeWarning(root) {
|
|
|
5503
5557
|
return `Injection needs @penvhq/penv ${INJECT_MIN_VERSION}+ \u2014 this project has ${version}, whose \`load\` ignores \`{ inject: true }\`. Upgrade, or process.env stays empty.`;
|
|
5504
5558
|
}
|
|
5505
5559
|
function installedPenvVersion(root) {
|
|
5506
|
-
const file =
|
|
5560
|
+
const file = join10(root, "node_modules", "@penvhq", "penv", "package.json");
|
|
5507
5561
|
if (!existsSync8(file)) {
|
|
5508
5562
|
return void 0;
|
|
5509
5563
|
}
|
|
@@ -5548,7 +5602,7 @@ function writeSeam(root, decisions = DEFAULT_DECISIONS, framework = detectFramew
|
|
|
5548
5602
|
};
|
|
5549
5603
|
}
|
|
5550
5604
|
const alsoNote = writeAlso(root, seam.also);
|
|
5551
|
-
const file =
|
|
5605
|
+
const file = join10(root, ...seam.file.split("/"));
|
|
5552
5606
|
const baseNotes = [...seam.notes, ...alsoNote === void 0 ? [] : [alsoNote]];
|
|
5553
5607
|
const notes = baseNotes.length === 0 ? "" : `
|
|
5554
5608
|
${baseNotes.map((n) => ` ${n}`).join("\n")}`;
|
|
@@ -5573,7 +5627,7 @@ function writeAlso(root, also) {
|
|
|
5573
5627
|
if (also === void 0) {
|
|
5574
5628
|
return void 0;
|
|
5575
5629
|
}
|
|
5576
|
-
const file =
|
|
5630
|
+
const file = join10(root, ...also.file.split("/"));
|
|
5577
5631
|
if (existsSync8(file)) {
|
|
5578
5632
|
return also.ifPresent;
|
|
5579
5633
|
}
|
|
@@ -5604,7 +5658,7 @@ function scaffold(root, fields, draft, decisions = DEFAULT_DECISIONS, framework
|
|
|
5604
5658
|
return seam === void 0 ? steps : [...steps, seam];
|
|
5605
5659
|
}
|
|
5606
5660
|
function scaffoldPaths(root, decisions = DEFAULT_DECISIONS, framework = detectFramework(root)?.name) {
|
|
5607
|
-
const fileAt = (relative5) =>
|
|
5661
|
+
const fileAt = (relative5) => join10(root, ...relative5.split("/"));
|
|
5608
5662
|
const seam = decisions.inject ? seamFor(framework, {
|
|
5609
5663
|
alias: decisions.alias,
|
|
5610
5664
|
srcDir: srcPrefix(root),
|
|
@@ -5682,7 +5736,7 @@ function planCutover(input) {
|
|
|
5682
5736
|
const diagnostics = [];
|
|
5683
5737
|
let variables = 0;
|
|
5684
5738
|
for (const file of selected) {
|
|
5685
|
-
const parsed = parseDotenv(readFileSync9(
|
|
5739
|
+
const parsed = parseDotenv(readFileSync9(join10(root, file.name), "utf8"));
|
|
5686
5740
|
const fileRefs = refsForEntries(parsed.entries, file.name, config);
|
|
5687
5741
|
adopted.push({ file, entries: parsed.entries, refs: fileRefs, scope: scopeOf(file) });
|
|
5688
5742
|
refs.push(...fileRefs);
|
|
@@ -5926,7 +5980,7 @@ function dailyCommand(root) {
|
|
|
5926
5980
|
return `penv run -- ${detectPackageManager(root)} ${devScript(root)}`;
|
|
5927
5981
|
}
|
|
5928
5982
|
function devScript(root) {
|
|
5929
|
-
const file =
|
|
5983
|
+
const file = join10(root, PACKAGE_FILE);
|
|
5930
5984
|
if (!existsSync8(file)) {
|
|
5931
5985
|
return "dev";
|
|
5932
5986
|
}
|
|
@@ -6666,7 +6720,7 @@ import {
|
|
|
6666
6720
|
rmSync as rmSync2,
|
|
6667
6721
|
writeFileSync as writeFileSync6
|
|
6668
6722
|
} from "fs";
|
|
6669
|
-
import { dirname as dirname7, join as
|
|
6723
|
+
import { dirname as dirname7, join as join11 } from "path";
|
|
6670
6724
|
import { createInterface as createInterface3 } from "readline/promises";
|
|
6671
6725
|
import {
|
|
6672
6726
|
loadConfig as loadConfig2,
|
|
@@ -6697,7 +6751,7 @@ function planMigrate(cwd) {
|
|
|
6697
6751
|
if (entries.length > 0 && !existsSync10(tree)) {
|
|
6698
6752
|
creates.push(`${RECORDS_PATH5}/`);
|
|
6699
6753
|
}
|
|
6700
|
-
if (readIfPresent(
|
|
6754
|
+
if (readIfPresent(join11(root, ...STATE_GITIGNORE_PATH2.split("/"))) !== renderStateGitignore2(config)) {
|
|
6701
6755
|
creates.push(STATE_GITIGNORE_PATH2);
|
|
6702
6756
|
}
|
|
6703
6757
|
return {
|
|
@@ -6707,7 +6761,7 @@ function planMigrate(cwd) {
|
|
|
6707
6761
|
to: `${RECORDS_PATH5}/${entry}`
|
|
6708
6762
|
})),
|
|
6709
6763
|
creates,
|
|
6710
|
-
removes: existsSync10(
|
|
6764
|
+
removes: existsSync10(join11(root, ...OLD_GITIGNORE.split("/"))) ? [OLD_GITIGNORE] : []
|
|
6711
6765
|
};
|
|
6712
6766
|
}
|
|
6713
6767
|
function readIfPresent(file) {
|
|
@@ -6737,16 +6791,16 @@ function applyMigrate(plan2) {
|
|
|
6737
6791
|
if (plan2.moves.length > 0) {
|
|
6738
6792
|
mkdirSync5(recordsDir3(plan2.root), { recursive: true });
|
|
6739
6793
|
for (const move of plan2.moves) {
|
|
6740
|
-
renameSync2(
|
|
6794
|
+
renameSync2(join11(plan2.root, ...move.from.split("/")), join11(plan2.root, ...move.to.split("/")));
|
|
6741
6795
|
}
|
|
6742
6796
|
}
|
|
6743
6797
|
if (plan2.creates.includes(STATE_GITIGNORE_PATH2)) {
|
|
6744
|
-
const ignore =
|
|
6798
|
+
const ignore = join11(plan2.root, ...STATE_GITIGNORE_PATH2.split("/"));
|
|
6745
6799
|
mkdirSync5(dirname7(ignore), { recursive: true });
|
|
6746
6800
|
writeFileSync6(ignore, renderStateGitignore2(config), "utf8");
|
|
6747
6801
|
}
|
|
6748
6802
|
for (const removed of plan2.removes) {
|
|
6749
|
-
rmSync2(
|
|
6803
|
+
rmSync2(join11(plan2.root, ...removed.split("/")), { force: true });
|
|
6750
6804
|
}
|
|
6751
6805
|
return { ...plan2, status: "migrated" };
|
|
6752
6806
|
}
|