@highstate/cli 0.19.1 → 0.21.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/assets/template/package.tpl.json +1 -8
- package/assets/template/packages/units/package.tpl.json +1 -3
- package/assets/tsconfig.base.json +1 -0
- package/dist/{chunk-6X5WTUTR.js → chunk-n0q0pces.js} +521 -581
- package/dist/{library-loader-PZWYMBAE.js → chunk-sxh2gdkm.js} +21 -17
- package/dist/{chunk-CMECLVT7.js → chunk-vcev74he.js} +4 -3
- package/dist/commands/index.js +30 -4
- package/dist/highstate.manifest.json +2 -2
- package/dist/main.js +19 -7
- package/package.json +13 -14
- package/src/commands/build.ts +36 -20
- package/src/commands/designer.ts +2 -25
- package/src/commands/init.ts +6 -66
- package/src/commands/update.ts +26 -31
- package/src/shared/bin-transformer.ts +2 -3
- package/src/shared/index.ts +0 -1
- package/src/shared/logger.ts +56 -0
- package/src/shared/overrides.ts +5 -41
- package/src/shared/project-versions.ts +6 -31
- package/src/shared/pulumi-cli.ts +5 -2
- package/src/shared/schema-transformer.spec.ts +15 -0
- package/src/shared/schema-transformer.ts +31 -2
- package/src/shared/source-hash-calculator.ts +55 -2
- package/LICENSE +0 -21
- package/assets/template/pnpm-workspace.tpl.yaml +0 -4
- package/dist/chunk-6X5WTUTR.js.map +0 -1
- package/dist/chunk-CMECLVT7.js.map +0 -1
- package/dist/commands/index.js.map +0 -1
- package/dist/library-loader-PZWYMBAE.js.map +0 -1
- package/dist/main.js.map +0 -1
- package/src/shared/pnpm-workspace.ts +0 -32
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { encode } from '@msgpack/msgpack';
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
int32ToBytes
|
|
4
|
+
} from "./chunk-vcev74he.js";
|
|
6
5
|
|
|
6
|
+
// src/shared/library-loader.ts
|
|
7
|
+
import console from "console";
|
|
8
|
+
import { Crc32, crc32 } from "@aws-crypto/crc32";
|
|
9
|
+
import {
|
|
10
|
+
isComponent,
|
|
11
|
+
isEntity,
|
|
12
|
+
isUnitModel
|
|
13
|
+
} from "@highstate/contract";
|
|
14
|
+
import { encode } from "@msgpack/msgpack";
|
|
7
15
|
async function loadLibrary(logger, modulePaths) {
|
|
8
16
|
const modules = {};
|
|
9
17
|
for (const modulePath of modulePaths) {
|
|
@@ -19,13 +27,10 @@ async function loadLibrary(logger, modulePaths) {
|
|
|
19
27
|
const components = {};
|
|
20
28
|
const entities = {};
|
|
21
29
|
await _loadLibrary(modules, components, entities);
|
|
22
|
-
logger.info(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
"library loaded"
|
|
28
|
-
);
|
|
30
|
+
logger.info({
|
|
31
|
+
componentCount: Object.keys(components).length,
|
|
32
|
+
entityCount: Object.keys(entities).length
|
|
33
|
+
}, "library loaded");
|
|
29
34
|
logger.trace({ components, entities }, "library content");
|
|
30
35
|
return { components, entities };
|
|
31
36
|
}
|
|
@@ -63,7 +68,7 @@ async function _loadLibrary(value, components, entities) {
|
|
|
63
68
|
}
|
|
64
69
|
}
|
|
65
70
|
async function calculateComponentDefinitionHash(component, entityHashes) {
|
|
66
|
-
const result = new Crc32
|
|
71
|
+
const result = new Crc32;
|
|
67
72
|
result.update(encode(component.model));
|
|
68
73
|
if (!isUnitModel(component.model)) {
|
|
69
74
|
const serializedCreate = { text: "TODO: investigate why serializeFunction hangs" };
|
|
@@ -77,7 +82,6 @@ async function calculateComponentDefinitionHash(component, entityHashes) {
|
|
|
77
82
|
function calculateEntityDefinitionHash(entity) {
|
|
78
83
|
return crc32(encode(entity.model));
|
|
79
84
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
//# sourceMappingURL=library-loader-PZWYMBAE.js.map
|
|
85
|
+
export {
|
|
86
|
+
loadLibrary
|
|
87
|
+
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __require = import.meta.require;
|
|
3
|
+
|
|
1
4
|
// src/shared/utils.ts
|
|
2
5
|
function int32ToBytes(value) {
|
|
3
6
|
const buffer = new ArrayBuffer(4);
|
|
@@ -6,6 +9,4 @@ function int32ToBytes(value) {
|
|
|
6
9
|
return new Uint8Array(buffer);
|
|
7
10
|
}
|
|
8
11
|
|
|
9
|
-
export { int32ToBytes };
|
|
10
|
-
//# sourceMappingURL=chunk-CMECLVT7.js.map
|
|
11
|
-
//# sourceMappingURL=chunk-CMECLVT7.js.map
|
|
12
|
+
export { __require, int32ToBytes };
|
package/dist/commands/index.js
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
BackendIdentityCommand,
|
|
4
|
+
BackendUnlockMethodAddCommand,
|
|
5
|
+
BackendUnlockMethodDeleteCommand,
|
|
6
|
+
BackendUnlockMethodListCommand,
|
|
7
|
+
BuildCommand,
|
|
8
|
+
DesignerCommand,
|
|
9
|
+
InitCommand,
|
|
10
|
+
PackageCreateCommand,
|
|
11
|
+
PackageListCommand,
|
|
12
|
+
PackageRemoveCommand,
|
|
13
|
+
PackageUpdateReferencesCommand,
|
|
14
|
+
UpdateCommand
|
|
15
|
+
} from "../chunk-n0q0pces.js";
|
|
16
|
+
import"../chunk-vcev74he.js";
|
|
17
|
+
export {
|
|
18
|
+
UpdateCommand,
|
|
19
|
+
PackageUpdateReferencesCommand,
|
|
20
|
+
PackageRemoveCommand,
|
|
21
|
+
PackageListCommand,
|
|
22
|
+
PackageCreateCommand,
|
|
23
|
+
InitCommand,
|
|
24
|
+
DesignerCommand,
|
|
25
|
+
BuildCommand,
|
|
26
|
+
BackendUnlockMethodListCommand,
|
|
27
|
+
BackendUnlockMethodDeleteCommand,
|
|
28
|
+
BackendUnlockMethodAddCommand,
|
|
29
|
+
BackendIdentityCommand
|
|
30
|
+
};
|
package/dist/main.js
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
3
|
+
import {
|
|
4
|
+
BackendIdentityCommand,
|
|
5
|
+
BackendUnlockMethodAddCommand,
|
|
6
|
+
BackendUnlockMethodDeleteCommand,
|
|
7
|
+
BackendUnlockMethodListCommand,
|
|
8
|
+
BuildCommand,
|
|
9
|
+
DesignerCommand,
|
|
10
|
+
InitCommand,
|
|
11
|
+
PackageCreateCommand,
|
|
12
|
+
PackageListCommand,
|
|
13
|
+
PackageRemoveCommand,
|
|
14
|
+
PackageUpdateReferencesCommand,
|
|
15
|
+
UpdateCommand
|
|
16
|
+
} from "./chunk-n0q0pces.js";
|
|
17
|
+
import"./chunk-vcev74he.js";
|
|
5
18
|
|
|
19
|
+
// src/main.ts
|
|
20
|
+
import { Builtins, Cli } from "clipanion";
|
|
6
21
|
var cli = new Cli({
|
|
7
22
|
binaryName: "highstate",
|
|
8
23
|
binaryLabel: "Highstate"
|
|
9
|
-
// binaryVersion: version,
|
|
10
24
|
});
|
|
11
25
|
cli.register(BuildCommand);
|
|
12
26
|
cli.register(DesignerCommand);
|
|
@@ -23,5 +37,3 @@ cli.register(PackageRemoveCommand);
|
|
|
23
37
|
cli.register(Builtins.HelpCommand);
|
|
24
38
|
cli.register(Builtins.VersionCommand);
|
|
25
39
|
await cli.runExit(process.argv.slice(2));
|
|
26
|
-
//# sourceMappingURL=main.js.map
|
|
27
|
-
//# sourceMappingURL=main.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@highstate/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"description": "The CLI for the Highstate project.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -25,11 +25,20 @@
|
|
|
25
25
|
"platform"
|
|
26
26
|
]
|
|
27
27
|
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "bun run --bun highstate build",
|
|
30
|
+
"test": "bun run --bun vitest run",
|
|
31
|
+
"typecheck": "tsgo --noEmit --skipLibCheck",
|
|
32
|
+
"biome": "biome check --write --unsafe --error-on-warnings",
|
|
33
|
+
"biome:check": "biome check --error-on-warnings"
|
|
34
|
+
},
|
|
28
35
|
"dependencies": {
|
|
29
36
|
"@aws-crypto/crc32": "^5.2.0",
|
|
37
|
+
"@highstate/backend": "0.20.0",
|
|
38
|
+
"@highstate/contract": "0.20.0",
|
|
30
39
|
"@inquirer/prompts": "^7.8.6",
|
|
31
40
|
"@msgpack/msgpack": "^3.1.2",
|
|
32
|
-
"@pulumi/pulumi": "3.
|
|
41
|
+
"@pulumi/pulumi": "3.232.0",
|
|
33
42
|
"age-encryption": "^0.2.4",
|
|
34
43
|
"ajv": "^8.17.1",
|
|
35
44
|
"clipanion": "^4.0.0-rc.4",
|
|
@@ -49,9 +58,7 @@
|
|
|
49
58
|
"semver": "^7.7.3",
|
|
50
59
|
"tsup": "^8.4.0",
|
|
51
60
|
"yaml": "^2.8.2",
|
|
52
|
-
"zod": "^4.0.5"
|
|
53
|
-
"@highstate/backend": "0.19.1",
|
|
54
|
-
"@highstate/contract": "0.19.1"
|
|
61
|
+
"zod": "^4.0.5"
|
|
55
62
|
},
|
|
56
63
|
"peerDependenciesMeta": {
|
|
57
64
|
"@pulumi/pulumi": {
|
|
@@ -66,17 +73,9 @@
|
|
|
66
73
|
"@types/semver": "^7.7.1",
|
|
67
74
|
"@typescript/native-preview": "^7.0.0-dev.20250920.1",
|
|
68
75
|
"esbuild": "^0.25.11",
|
|
69
|
-
"highstate-cli-bootstrap": "npm:@highstate/cli",
|
|
70
76
|
"vitest": "^3.2.4"
|
|
71
77
|
},
|
|
72
78
|
"repository": {
|
|
73
79
|
"url": "https://github.com/highstate-io/highstate"
|
|
74
|
-
},
|
|
75
|
-
"scripts": {
|
|
76
|
-
"build": "highstate build",
|
|
77
|
-
"test": "vitest run",
|
|
78
|
-
"typecheck": "tsgo --noEmit --skipLibCheck",
|
|
79
|
-
"biome": "biome check --write --unsafe --error-on-warnings",
|
|
80
|
-
"biome:check": "biome check --error-on-warnings"
|
|
81
80
|
}
|
|
82
|
-
}
|
|
81
|
+
}
|
package/src/commands/build.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { writeFile } from "node:fs/promises"
|
|
1
|
+
import { chmod, readFile, rm, writeFile } from "node:fs/promises"
|
|
3
2
|
import { resolve } from "node:path"
|
|
4
3
|
import { encode } from "@msgpack/msgpack"
|
|
5
4
|
import { Command, Option } from "clipanion"
|
|
6
5
|
import { readPackageJSON, resolvePackageJSON } from "pkg-types"
|
|
7
|
-
import { mapValues } from "remeda"
|
|
8
|
-
import { build } from "tsup"
|
|
9
6
|
import {
|
|
10
7
|
createBinTransformerPlugin,
|
|
11
8
|
extractEntryPoints,
|
|
@@ -23,7 +20,6 @@ export class BuildCommand extends Command {
|
|
|
23
20
|
description: "Builds the Highstate library or unit package.",
|
|
24
21
|
})
|
|
25
22
|
|
|
26
|
-
watch = Option.Boolean("--watch", false)
|
|
27
23
|
library = Option.Boolean("--library", false)
|
|
28
24
|
silent = Option.Boolean("--silent", true)
|
|
29
25
|
noSourceHash = Option.Boolean("--no-source-hash", false)
|
|
@@ -50,36 +46,56 @@ export class BuildCommand extends Command {
|
|
|
50
46
|
return
|
|
51
47
|
}
|
|
52
48
|
|
|
53
|
-
const
|
|
49
|
+
const bunPlugins: Bun.BunPlugin[] = []
|
|
54
50
|
|
|
55
51
|
const binSourceFilePaths = Object.values(entryPoints)
|
|
56
52
|
.filter(value => value.isBin)
|
|
57
53
|
.map(value => value.entryPoint.slice(2)) // remove "./"
|
|
58
54
|
|
|
59
55
|
if (this.library) {
|
|
60
|
-
|
|
56
|
+
bunPlugins.push(schemaTransformerPlugin)
|
|
61
57
|
}
|
|
62
58
|
|
|
63
59
|
if (binSourceFilePaths.length > 0) {
|
|
64
|
-
|
|
60
|
+
bunPlugins.push(createBinTransformerPlugin(binSourceFilePaths))
|
|
65
61
|
}
|
|
66
62
|
|
|
67
|
-
await
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
await rm("dist", { recursive: true, force: true })
|
|
64
|
+
|
|
65
|
+
const bunEntryPoints = Object.values(entryPoints).map(value => value.entryPoint)
|
|
66
|
+
|
|
67
|
+
const result = await Bun.build({
|
|
68
|
+
entrypoints: bunEntryPoints,
|
|
69
|
+
outdir: "dist",
|
|
70
|
+
root: "./src",
|
|
73
71
|
format: "esm",
|
|
74
|
-
target: "
|
|
75
|
-
platform: "node",
|
|
72
|
+
target: "bun",
|
|
76
73
|
external: ["@pulumi/pulumi"],
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
silent: this.silent || ["warn", "error", "fatal"].includes(logger.level),
|
|
74
|
+
packages: "external",
|
|
75
|
+
splitting: true,
|
|
76
|
+
plugins: bunPlugins,
|
|
81
77
|
})
|
|
82
78
|
|
|
79
|
+
if (!result.success) {
|
|
80
|
+
for (const log of result.logs) {
|
|
81
|
+
logger.error(log.message)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
throw new Error("build failed")
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const binEntryPoints = Object.values(entryPoints).filter(value => value.isBin)
|
|
88
|
+
for (const binEntryPoint of binEntryPoints) {
|
|
89
|
+
const binPath = resolve(binEntryPoint.distPath)
|
|
90
|
+
const binContent = await readFile(binPath, "utf8")
|
|
91
|
+
|
|
92
|
+
if (!binContent.startsWith("#!/usr/bin/env bun\n")) {
|
|
93
|
+
await writeFile(binPath, `#!/usr/bin/env bun\n${binContent}`, "utf8")
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
await chmod(binPath, 0o755)
|
|
97
|
+
}
|
|
98
|
+
|
|
83
99
|
const packageJsonPath = await resolvePackageJSON()
|
|
84
100
|
const upToDatePackageJson = await readPackageJSON()
|
|
85
101
|
|
package/src/commands/designer.ts
CHANGED
|
@@ -4,14 +4,9 @@ import { consola } from "consola"
|
|
|
4
4
|
import { colorize } from "consola/utils"
|
|
5
5
|
import { getPort } from "get-port-please"
|
|
6
6
|
import { resolve as importMetaResolve } from "import-meta-resolve"
|
|
7
|
-
import { addDevDependency
|
|
7
|
+
import { addDevDependency } from "nypm"
|
|
8
8
|
import { readPackageJSON, resolvePackageJSON } from "pkg-types"
|
|
9
|
-
import {
|
|
10
|
-
getBackendServices,
|
|
11
|
-
getProjectPulumiSdkVersion,
|
|
12
|
-
getPulumiCliVersion,
|
|
13
|
-
logger,
|
|
14
|
-
} from "../shared"
|
|
9
|
+
import { getBackendServices, logger } from "../shared"
|
|
15
10
|
|
|
16
11
|
export class DesignerCommand extends Command {
|
|
17
12
|
static paths = [["designer"]]
|
|
@@ -38,24 +33,6 @@ export class DesignerCommand extends Command {
|
|
|
38
33
|
await addDevDependency(["@highstate/designer", "classic-level"])
|
|
39
34
|
}
|
|
40
35
|
|
|
41
|
-
const projectRoot = process.cwd()
|
|
42
|
-
const detected = await detectPackageManager(projectRoot)
|
|
43
|
-
const packageManager = detected?.name
|
|
44
|
-
|
|
45
|
-
if (packageManager === "npm" || packageManager === "pnpm" || packageManager === "yarn") {
|
|
46
|
-
const expectedPulumiSdk = await getProjectPulumiSdkVersion(projectRoot, { packageManager })
|
|
47
|
-
const actualPulumiCli = await getPulumiCliVersion(projectRoot)
|
|
48
|
-
|
|
49
|
-
if (expectedPulumiSdk && actualPulumiCli && expectedPulumiSdk !== actualPulumiCli) {
|
|
50
|
-
logger.warn(
|
|
51
|
-
`pulumi version mismatch detected, this may cause incompatibilities\nexpected "%s" (from overrides for "@pulumi/pulumi"), got "%s" (from "pulumi version")\nrecommended: run "highstate update" or downgrade your Pulumi CLI to "%s"`,
|
|
52
|
-
expectedPulumiSdk,
|
|
53
|
-
actualPulumiCli,
|
|
54
|
-
expectedPulumiSdk,
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
36
|
logger.info("starting highstate designer...")
|
|
60
37
|
|
|
61
38
|
await getBackendServices()
|
package/src/commands/init.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { PackageManagerName } from "nypm"
|
|
2
1
|
import { access, mkdir, readdir } from "node:fs/promises"
|
|
3
2
|
import { resolve } from "node:path"
|
|
4
3
|
import { fileURLToPath } from "node:url"
|
|
5
|
-
import { input
|
|
4
|
+
import { input } from "@inquirer/prompts"
|
|
6
5
|
import { Command, Option } from "clipanion"
|
|
7
6
|
import { installDependencies } from "nypm"
|
|
8
7
|
import {
|
|
@@ -24,10 +23,6 @@ export class InitCommand extends Command {
|
|
|
24
23
|
description: "The path where the project should be initialized.",
|
|
25
24
|
})
|
|
26
25
|
|
|
27
|
-
packageManager = Option.String("--package-manager", {
|
|
28
|
-
description: "The package manager to use (npm, yarn, pnpm).",
|
|
29
|
-
})
|
|
30
|
-
|
|
31
26
|
name = Option.String("--name", {
|
|
32
27
|
description: "The project name.",
|
|
33
28
|
})
|
|
@@ -41,19 +36,14 @@ export class InitCommand extends Command {
|
|
|
41
36
|
})
|
|
42
37
|
|
|
43
38
|
async execute(): Promise<void> {
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
46
|
-
throw new Error('
|
|
39
|
+
const isBunAvailable = await isExecutableInPath("bun")
|
|
40
|
+
if (!isBunAvailable) {
|
|
41
|
+
throw new Error('Required package manager "bun" was not found in PATH')
|
|
47
42
|
}
|
|
48
43
|
|
|
49
44
|
const projectName = await resolveProjectName(this.name)
|
|
50
45
|
const destinationPath = await resolveDestinationPath(this.pathOption, projectName)
|
|
51
46
|
|
|
52
|
-
const selectedPackageManager = await resolvePackageManager(
|
|
53
|
-
this.packageManager,
|
|
54
|
-
availablePackageManagers,
|
|
55
|
-
)
|
|
56
|
-
|
|
57
47
|
const templatePath = resolveTemplatePath()
|
|
58
48
|
|
|
59
49
|
const versionBundle = await resolveVersionBundle({
|
|
@@ -75,23 +65,19 @@ export class InitCommand extends Command {
|
|
|
75
65
|
packageName: projectName,
|
|
76
66
|
platformVersion: versionBundle.platformVersion,
|
|
77
67
|
libraryVersion: versionBundle.stdlibVersion,
|
|
78
|
-
isPnpm: selectedPackageManager === "pnpm" ? "true" : "",
|
|
79
|
-
isYarn: selectedPackageManager === "yarn" ? "true" : "",
|
|
80
|
-
isNpm: selectedPackageManager === "npm" ? "true" : "",
|
|
81
68
|
})
|
|
82
69
|
|
|
83
70
|
const overrides = buildOverrides(versionBundle)
|
|
84
71
|
await applyOverrides({
|
|
85
72
|
projectRoot: destinationPath,
|
|
86
|
-
packageManager: selectedPackageManager,
|
|
87
73
|
overrides,
|
|
88
74
|
})
|
|
89
75
|
|
|
90
|
-
logger.info("installing dependencies using
|
|
76
|
+
logger.info("installing dependencies using bun...")
|
|
91
77
|
|
|
92
78
|
await installDependencies({
|
|
93
79
|
cwd: destinationPath,
|
|
94
|
-
packageManager:
|
|
80
|
+
packageManager: "bun",
|
|
95
81
|
silent: false,
|
|
96
82
|
})
|
|
97
83
|
|
|
@@ -137,52 +123,6 @@ async function resolveProjectName(nameOption: string | undefined): Promise<strin
|
|
|
137
123
|
return value.trim()
|
|
138
124
|
}
|
|
139
125
|
|
|
140
|
-
async function resolvePackageManager(
|
|
141
|
-
packageManagerOption: string | undefined,
|
|
142
|
-
available: PackageManagerName[],
|
|
143
|
-
): Promise<PackageManagerName> {
|
|
144
|
-
if (packageManagerOption) {
|
|
145
|
-
if (!isSupportedPackageManagerName(packageManagerOption)) {
|
|
146
|
-
throw new Error(`Unsupported package manager: "${packageManagerOption}"`)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const name = packageManagerOption
|
|
150
|
-
if (!available.includes(name)) {
|
|
151
|
-
throw new Error(`Package manager not found in PATH: "${name}"`)
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return name
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const preferredOrder: PackageManagerName[] = ["pnpm", "yarn", "npm"]
|
|
158
|
-
const defaultValue = preferredOrder.find(value => available.includes(value)) ?? available[0]
|
|
159
|
-
|
|
160
|
-
return await select({
|
|
161
|
-
message: "Package manager",
|
|
162
|
-
default: defaultValue,
|
|
163
|
-
choices: available.map(value => ({ name: value, value })),
|
|
164
|
-
})
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function isSupportedPackageManagerName(value: string): value is PackageManagerName {
|
|
168
|
-
return value === "npm" || value === "pnpm" || value === "yarn"
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
async function detectAvailablePackageManagers(
|
|
172
|
-
candidates: PackageManagerName[],
|
|
173
|
-
): Promise<PackageManagerName[]> {
|
|
174
|
-
const results: PackageManagerName[] = []
|
|
175
|
-
|
|
176
|
-
for (const candidate of candidates) {
|
|
177
|
-
const exists = await isExecutableInPath(candidate)
|
|
178
|
-
if (exists) {
|
|
179
|
-
results.push(candidate)
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return results
|
|
184
|
-
}
|
|
185
|
-
|
|
186
126
|
async function isExecutableInPath(command: string): Promise<boolean> {
|
|
187
127
|
const pathValue = process.env.PATH
|
|
188
128
|
if (!pathValue) {
|
package/src/commands/update.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises"
|
|
2
2
|
import { Command, Option } from "clipanion"
|
|
3
|
-
import {
|
|
3
|
+
import { readPackageJSON, resolvePackageJSON } from "pkg-types"
|
|
4
4
|
import semver from "semver"
|
|
5
5
|
import {
|
|
6
6
|
applyOverrides,
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
getProjectPlatformVersion,
|
|
11
11
|
logger,
|
|
12
12
|
resolveVersionBundle,
|
|
13
|
+
writeJsonFile,
|
|
13
14
|
} from "../shared"
|
|
14
15
|
|
|
15
16
|
export class UpdateCommand extends Command {
|
|
@@ -42,7 +43,7 @@ export class UpdateCommand extends Command {
|
|
|
42
43
|
async execute(): Promise<void> {
|
|
43
44
|
const projectRoot = process.cwd()
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
await assertPackageJsonExists(projectRoot)
|
|
46
47
|
|
|
47
48
|
if (this.platformOnly && this.stdlibOnly) {
|
|
48
49
|
throw new Error('Flags "--platform" and "--stdlib" cannot be used together')
|
|
@@ -52,9 +53,7 @@ export class UpdateCommand extends Command {
|
|
|
52
53
|
const updateStdlib = this.stdlibOnly || !this.platformOnly
|
|
53
54
|
|
|
54
55
|
if (this.stdlibOnly) {
|
|
55
|
-
const currentPlatformVersion = await getProjectPlatformVersion(projectRoot
|
|
56
|
-
packageManager,
|
|
57
|
-
})
|
|
56
|
+
const currentPlatformVersion = await getProjectPlatformVersion(projectRoot)
|
|
58
57
|
if (!currentPlatformVersion) {
|
|
59
58
|
throw new Error('Current platform version is not set in overrides for "@highstate/pulumi"')
|
|
60
59
|
}
|
|
@@ -97,9 +96,12 @@ export class UpdateCommand extends Command {
|
|
|
97
96
|
const overrides = buildOverrides(bundle)
|
|
98
97
|
await applyOverrides({
|
|
99
98
|
projectRoot,
|
|
100
|
-
packageManager,
|
|
101
99
|
overrides,
|
|
102
100
|
})
|
|
101
|
+
await syncRootPulumiDependency({
|
|
102
|
+
projectRoot,
|
|
103
|
+
pulumiVersion: bundle.pulumiVersion,
|
|
104
|
+
})
|
|
103
105
|
|
|
104
106
|
logger.info(
|
|
105
107
|
"updated overrides: platform=%s stdlib=%s pulumi=%s",
|
|
@@ -111,11 +113,11 @@ export class UpdateCommand extends Command {
|
|
|
111
113
|
if (this.install) {
|
|
112
114
|
const { installDependencies } = await import("nypm")
|
|
113
115
|
|
|
114
|
-
logger.info("installing dependencies using
|
|
116
|
+
logger.info("installing dependencies using bun...")
|
|
115
117
|
|
|
116
118
|
await installDependencies({
|
|
117
119
|
cwd: projectRoot,
|
|
118
|
-
packageManager,
|
|
120
|
+
packageManager: "bun",
|
|
119
121
|
silent: false,
|
|
120
122
|
})
|
|
121
123
|
}
|
|
@@ -124,29 +126,6 @@ export class UpdateCommand extends Command {
|
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
async function resolveProjectPackageManager(projectRoot: string) {
|
|
128
|
-
const detected = await detectPackageManager(projectRoot)
|
|
129
|
-
if (!detected?.name) {
|
|
130
|
-
throw new Error("Unable to detect package manager for this project")
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (detected.name === "bun") {
|
|
134
|
-
throw new Error('Package manager "bun" is not supported')
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (detected.name === "deno") {
|
|
138
|
-
throw new Error('Package manager "deno" is not supported')
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (detected.name !== "npm" && detected.name !== "pnpm" && detected.name !== "yarn") {
|
|
142
|
-
throw new Error(`Unsupported package manager: "${detected.name}"`)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
await assertPackageJsonExists(projectRoot)
|
|
146
|
-
|
|
147
|
-
return detected.name
|
|
148
|
-
}
|
|
149
|
-
|
|
150
129
|
async function assertPackageJsonExists(projectRoot: string): Promise<void> {
|
|
151
130
|
try {
|
|
152
131
|
await readFile(`${projectRoot}/package.json`, "utf8")
|
|
@@ -154,3 +133,19 @@ async function assertPackageJsonExists(projectRoot: string): Promise<void> {
|
|
|
154
133
|
throw new Error(`File "package.json" not found in "${projectRoot}"`)
|
|
155
134
|
}
|
|
156
135
|
}
|
|
136
|
+
|
|
137
|
+
async function syncRootPulumiDependency(args: {
|
|
138
|
+
projectRoot: string
|
|
139
|
+
pulumiVersion: string
|
|
140
|
+
}): Promise<void> {
|
|
141
|
+
const packageJsonPath = await resolvePackageJSON(args.projectRoot)
|
|
142
|
+
const packageJson = await readPackageJSON(packageJsonPath)
|
|
143
|
+
|
|
144
|
+
await writeJsonFile(packageJsonPath, {
|
|
145
|
+
...packageJson,
|
|
146
|
+
dependencies: {
|
|
147
|
+
...(packageJson.dependencies ?? {}),
|
|
148
|
+
"@pulumi/pulumi": args.pulumiVersion,
|
|
149
|
+
},
|
|
150
|
+
})
|
|
151
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { Plugin } from "esbuild"
|
|
2
1
|
import { readFile } from "node:fs/promises"
|
|
3
2
|
import { logger } from "./logger"
|
|
4
3
|
|
|
5
|
-
export function createBinTransformerPlugin(sourceFilePaths: string[]):
|
|
4
|
+
export function createBinTransformerPlugin(sourceFilePaths: string[]): Bun.BunPlugin {
|
|
6
5
|
const filter = new RegExp(`(${sourceFilePaths.join("|")})$`)
|
|
7
6
|
|
|
8
7
|
logger.debug("created bin transformer plugin with filter: %s", filter)
|
|
@@ -14,7 +13,7 @@ export function createBinTransformerPlugin(sourceFilePaths: string[]): Plugin {
|
|
|
14
13
|
const content = await readFile(args.path, "utf-8")
|
|
15
14
|
|
|
16
15
|
return {
|
|
17
|
-
contents: `#!/usr/bin/env
|
|
16
|
+
contents: `#!/usr/bin/env bun\n\n${content}`,
|
|
18
17
|
loader: "ts",
|
|
19
18
|
}
|
|
20
19
|
})
|
package/src/shared/index.ts
CHANGED
package/src/shared/logger.ts
CHANGED
|
@@ -6,6 +6,9 @@ export const logger = pino(
|
|
|
6
6
|
{
|
|
7
7
|
name: "highstate-cli",
|
|
8
8
|
level: process.env.LOG_LEVEL ?? "info",
|
|
9
|
+
serializers: {
|
|
10
|
+
error: value => serializeError(value),
|
|
11
|
+
},
|
|
9
12
|
},
|
|
10
13
|
createConsolaStream(),
|
|
11
14
|
)
|
|
@@ -52,3 +55,56 @@ function createConsolaStream() {
|
|
|
52
55
|
|
|
53
56
|
return stream
|
|
54
57
|
}
|
|
58
|
+
|
|
59
|
+
function serializeError(value: unknown, seen: WeakSet<object> = new WeakSet()): unknown {
|
|
60
|
+
if (value instanceof Error) {
|
|
61
|
+
const base: Record<string, unknown> = {
|
|
62
|
+
name: value.name,
|
|
63
|
+
message: value.message,
|
|
64
|
+
stack: value.stack,
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const cause = (value as Error & { cause?: unknown }).cause
|
|
68
|
+
if (cause !== undefined) {
|
|
69
|
+
base.cause = serializeError(cause, seen)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const extraEntries = Object.entries(value)
|
|
73
|
+
if (extraEntries.length > 0) {
|
|
74
|
+
base.details = Object.fromEntries(
|
|
75
|
+
extraEntries.map(([key, entryValue]) => [key, serializeError(entryValue, seen)]),
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return base
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (Array.isArray(value)) {
|
|
83
|
+
return value.map(entry => serializeError(entry, seen))
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (value && typeof value === "object") {
|
|
87
|
+
if (seen.has(value)) {
|
|
88
|
+
return "[Circular]"
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
seen.add(value)
|
|
92
|
+
|
|
93
|
+
const entries = Object.entries(value)
|
|
94
|
+
if (entries.length === 0) {
|
|
95
|
+
return {
|
|
96
|
+
type: value.constructor?.name ?? "Object",
|
|
97
|
+
message: String(value),
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return Object.fromEntries(
|
|
102
|
+
entries.map(([key, entryValue]) => [key, serializeError(entryValue, seen)]),
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
type: typeof value,
|
|
108
|
+
message: String(value),
|
|
109
|
+
}
|
|
110
|
+
}
|