@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
package/src/shared/overrides.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type { PackageManagerName } from "nypm"
|
|
2
1
|
import type { VersionBundle } from "./version-bundle"
|
|
3
|
-
import { access } from "node:fs/promises"
|
|
4
2
|
import { readPackageJSON, resolvePackageJSON } from "pkg-types"
|
|
5
3
|
import { writeJsonFile } from "./package-json"
|
|
6
|
-
import { readPnpmWorkspace, resolvePnpmWorkspacePath, writePnpmWorkspace } from "./pnpm-workspace"
|
|
7
4
|
import { PLATFORM_PACKAGES, PULUMI_PACKAGES, STDLIB_PACKAGES } from "./version-sets"
|
|
8
5
|
|
|
9
6
|
export type Overrides = Record<string, string>
|
|
@@ -23,51 +20,18 @@ export function buildOverrides(bundle: VersionBundle): Overrides {
|
|
|
23
20
|
}
|
|
24
21
|
|
|
25
22
|
export type ApplyOverridesArgs = {
|
|
26
|
-
packageManager: PackageManagerName
|
|
27
23
|
overrides: Overrides
|
|
28
24
|
projectRoot: string
|
|
29
25
|
}
|
|
30
26
|
|
|
31
27
|
export async function applyOverrides(args: ApplyOverridesArgs): Promise<void> {
|
|
32
|
-
const {
|
|
33
|
-
|
|
34
|
-
if (packageManager === "pnpm") {
|
|
35
|
-
const pnpmWorkspacePath = resolvePnpmWorkspacePath(projectRoot)
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
await access(pnpmWorkspacePath)
|
|
39
|
-
} catch {
|
|
40
|
-
throw new Error(`PNPM workspace file is missing: "${pnpmWorkspacePath}"`)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const workspace = await readPnpmWorkspace(pnpmWorkspacePath)
|
|
44
|
-
const nextWorkspace = {
|
|
45
|
-
...workspace,
|
|
46
|
-
overrides,
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
await writePnpmWorkspace(pnpmWorkspacePath, nextWorkspace)
|
|
50
|
-
return
|
|
51
|
-
}
|
|
28
|
+
const { overrides, projectRoot } = args
|
|
52
29
|
|
|
53
30
|
const packageJsonPath = await resolvePackageJSON(projectRoot)
|
|
54
31
|
const packageJson = await readPackageJSON(projectRoot)
|
|
55
32
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
})
|
|
61
|
-
return
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (packageManager === "yarn") {
|
|
65
|
-
await writeJsonFile(packageJsonPath, {
|
|
66
|
-
...packageJson,
|
|
67
|
-
resolutions: overrides,
|
|
68
|
-
})
|
|
69
|
-
return
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
await writeJsonFile(packageJsonPath, packageJson)
|
|
33
|
+
await writeJsonFile(packageJsonPath, {
|
|
34
|
+
...packageJson,
|
|
35
|
+
overrides,
|
|
36
|
+
})
|
|
73
37
|
}
|
|
@@ -1,54 +1,29 @@
|
|
|
1
|
-
import type { PackageManagerName } from "nypm"
|
|
2
1
|
import type { PackageJson } from "pkg-types"
|
|
3
2
|
import { readFile } from "node:fs/promises"
|
|
4
3
|
import { resolvePackageJSON } from "pkg-types"
|
|
5
|
-
import { readPnpmWorkspace, resolvePnpmWorkspacePath } from "./pnpm-workspace"
|
|
6
4
|
|
|
7
5
|
export async function getProjectOverrideVersion(
|
|
8
6
|
projectRoot: string,
|
|
9
|
-
args: {
|
|
7
|
+
args: { packageName: string },
|
|
10
8
|
): Promise<string | null> {
|
|
11
|
-
const {
|
|
12
|
-
|
|
13
|
-
if (packageManager === "pnpm") {
|
|
14
|
-
const path = resolvePnpmWorkspacePath(projectRoot)
|
|
15
|
-
const workspace = await readPnpmWorkspace(path)
|
|
16
|
-
return workspace.overrides?.[packageName] ?? null
|
|
17
|
-
}
|
|
9
|
+
const { packageName } = args
|
|
18
10
|
|
|
19
11
|
const packageJsonPath = await resolvePackageJSON(projectRoot)
|
|
20
12
|
const rawPackageJson = await readFile(packageJsonPath, "utf8")
|
|
21
13
|
const packageJson = JSON.parse(rawPackageJson) as PackageJson
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return overrides?.[packageName] ?? null
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (packageManager === "yarn") {
|
|
29
|
-
const resolutions = packageJson.resolutions as Record<string, string> | undefined
|
|
30
|
-
return resolutions?.[packageName] ?? null
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return null
|
|
15
|
+
const overrides = packageJson.overrides as Record<string, string> | undefined
|
|
16
|
+
return overrides?.[packageName] ?? null
|
|
34
17
|
}
|
|
35
18
|
|
|
36
|
-
export async function getProjectPlatformVersion(
|
|
37
|
-
projectRoot: string,
|
|
38
|
-
args: { packageManager: PackageManagerName },
|
|
39
|
-
): Promise<string | null> {
|
|
19
|
+
export async function getProjectPlatformVersion(projectRoot: string): Promise<string | null> {
|
|
40
20
|
return await getProjectOverrideVersion(projectRoot, {
|
|
41
|
-
packageManager: args.packageManager,
|
|
42
21
|
packageName: "@highstate/pulumi",
|
|
43
22
|
})
|
|
44
23
|
}
|
|
45
24
|
|
|
46
|
-
export async function getProjectPulumiSdkVersion(
|
|
47
|
-
projectRoot: string,
|
|
48
|
-
args: { packageManager: PackageManagerName },
|
|
49
|
-
): Promise<string | null> {
|
|
25
|
+
export async function getProjectPulumiSdkVersion(projectRoot: string): Promise<string | null> {
|
|
50
26
|
return await getProjectOverrideVersion(projectRoot, {
|
|
51
|
-
packageManager: args.packageManager,
|
|
52
27
|
packageName: "@pulumi/pulumi",
|
|
53
28
|
})
|
|
54
29
|
}
|
package/src/shared/pulumi-cli.ts
CHANGED
|
@@ -3,9 +3,12 @@ import { promisify } from "node:util"
|
|
|
3
3
|
|
|
4
4
|
const execFileAsync = promisify(execFile)
|
|
5
5
|
|
|
6
|
-
export async function getPulumiCliVersion(
|
|
6
|
+
export async function getPulumiCliVersion(
|
|
7
|
+
cwd: string,
|
|
8
|
+
commandPath = "pulumi",
|
|
9
|
+
): Promise<string | null> {
|
|
7
10
|
try {
|
|
8
|
-
const { stdout } = await execFileAsync(
|
|
11
|
+
const { stdout } = await execFileAsync(commandPath, ["version"], {
|
|
9
12
|
cwd,
|
|
10
13
|
})
|
|
11
14
|
|
|
@@ -696,4 +696,19 @@ export const testUnit = defineUnit({
|
|
|
696
696
|
const metaMatches = (result.match(/meta\s*:\s*\{/g) || []).length
|
|
697
697
|
expect(metaMatches).toBe(1)
|
|
698
698
|
})
|
|
699
|
+
|
|
700
|
+
it("should not transform runtime call input objects", async () => {
|
|
701
|
+
const input = `
|
|
702
|
+
const { addressSpace } = network.addressSpace({
|
|
703
|
+
name: "demo",
|
|
704
|
+
inputs: {
|
|
705
|
+
excludedL4Endpoints: l4Endpoints,
|
|
706
|
+
},
|
|
707
|
+
})`
|
|
708
|
+
|
|
709
|
+
const result = await applySchemaTransformations(input)
|
|
710
|
+
|
|
711
|
+
expect(result).toContain("excludedL4Endpoints: l4Endpoints")
|
|
712
|
+
expect(result).not.toContain("$addInputDescription(l4Endpoints")
|
|
713
|
+
})
|
|
699
714
|
})
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Plugin } from "esbuild"
|
|
2
1
|
import { readFile } from "node:fs/promises"
|
|
3
2
|
import MagicString from "magic-string"
|
|
4
3
|
import {
|
|
@@ -10,7 +9,7 @@ import {
|
|
|
10
9
|
} from "oxc-parser"
|
|
11
10
|
import { type Node, walk } from "oxc-walker"
|
|
12
11
|
|
|
13
|
-
export const schemaTransformerPlugin:
|
|
12
|
+
export const schemaTransformerPlugin: Bun.BunPlugin = {
|
|
14
13
|
name: "schema-transformer",
|
|
15
14
|
setup(build) {
|
|
16
15
|
build.onLoad({ filter: /src\/.*\.ts$/ }, async args => {
|
|
@@ -439,6 +438,10 @@ function getHelperFunctionForProperty(
|
|
|
439
438
|
containerParent.value === objectExpression &&
|
|
440
439
|
containerParent.key?.type === "Identifier"
|
|
441
440
|
) {
|
|
441
|
+
if (!isDefinitionLikeContext(parentStack)) {
|
|
442
|
+
return null
|
|
443
|
+
}
|
|
444
|
+
|
|
442
445
|
const keyName = containerParent.key.name
|
|
443
446
|
if (keyName === "inputs" || keyName === "outputs") {
|
|
444
447
|
return "$addInputDescription"
|
|
@@ -468,6 +471,32 @@ function getHelperFunctionForProperty(
|
|
|
468
471
|
return null
|
|
469
472
|
}
|
|
470
473
|
|
|
474
|
+
function isDefinitionLikeContext(parentStack: Node[]): boolean {
|
|
475
|
+
for (let i = parentStack.length - 1; i >= 0; i--) {
|
|
476
|
+
const node = parentStack[i]
|
|
477
|
+
if (node.type !== "CallExpression") {
|
|
478
|
+
continue
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (node.callee.type !== "Identifier") {
|
|
482
|
+
return false
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
return [
|
|
486
|
+
"defineComponent",
|
|
487
|
+
"defineUnit",
|
|
488
|
+
"defineEntity",
|
|
489
|
+
"$inputs",
|
|
490
|
+
"$outputs",
|
|
491
|
+
"$args",
|
|
492
|
+
"$secrets",
|
|
493
|
+
].includes(node.callee.name)
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// top-level literal specs (without define* wrappers) are still valid transform targets
|
|
497
|
+
return true
|
|
498
|
+
}
|
|
499
|
+
|
|
471
500
|
function isZodObjectCall(memberExpression: Node): boolean {
|
|
472
501
|
if (
|
|
473
502
|
memberExpression.type !== "MemberExpression" ||
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Logger } from "pino"
|
|
2
2
|
import { readFile, writeFile } from "node:fs/promises"
|
|
3
|
-
import {
|
|
3
|
+
import { builtinModules } from "node:module"
|
|
4
|
+
import { dirname, isAbsolute, relative, resolve } from "node:path"
|
|
4
5
|
import { fileURLToPath, pathToFileURL } from "node:url"
|
|
5
6
|
import { crc32 } from "@aws-crypto/crc32"
|
|
6
7
|
import { resolve as importMetaResolve } from "import-meta-resolve"
|
|
@@ -53,6 +54,19 @@ export function parseFileDependencies(filePath: string, content: string): FileDe
|
|
|
53
54
|
fullPath,
|
|
54
55
|
})
|
|
55
56
|
} else if (npmPackage) {
|
|
57
|
+
const normalizedPackageName = npmPackage.startsWith("node:")
|
|
58
|
+
? npmPackage.slice("node:".length)
|
|
59
|
+
: npmPackage
|
|
60
|
+
const builtinName = normalizedPackageName.split("/")[0]
|
|
61
|
+
if (
|
|
62
|
+
builtinModules.includes(normalizedPackageName) ||
|
|
63
|
+
builtinModules.includes(builtinName) ||
|
|
64
|
+
builtinModules.includes(`node:${normalizedPackageName}`) ||
|
|
65
|
+
builtinModules.includes(`node:${builtinName}`)
|
|
66
|
+
) {
|
|
67
|
+
continue
|
|
68
|
+
}
|
|
69
|
+
|
|
56
70
|
dependencies.push({
|
|
57
71
|
type: "npm",
|
|
58
72
|
id: `npm:${npmPackage}`,
|
|
@@ -255,7 +269,17 @@ export class SourceHashCalculator {
|
|
|
255
269
|
// throw new Error(`"${dependency.package}" imported without "node:" prefix`)
|
|
256
270
|
// }
|
|
257
271
|
|
|
258
|
-
const resolvedPath =
|
|
272
|
+
const resolvedPath = this.resolveDependencyPath(dependency.package, resolvedUrl)
|
|
273
|
+
if (!resolvedPath) {
|
|
274
|
+
this.logger.debug(
|
|
275
|
+
`using package version as a fallback hash for "%s" due to unsupported resolver output "%s"`,
|
|
276
|
+
dependency.package,
|
|
277
|
+
resolvedUrl,
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
const [, depPackageJson] = await this.getPackageJsonFromPackageName(dependency.package)
|
|
281
|
+
return this.hashString(depPackageJson.version ?? "0.0.0")
|
|
282
|
+
}
|
|
259
283
|
|
|
260
284
|
const [depPackageJsonPath, depPackageJson] = await this.getPackageJson(resolvedPath)
|
|
261
285
|
const packageName = depPackageJson.name!
|
|
@@ -310,6 +334,35 @@ export class SourceHashCalculator {
|
|
|
310
334
|
}
|
|
311
335
|
}
|
|
312
336
|
|
|
337
|
+
private resolveDependencyPath(packageName: string, resolvedUrl: string): string | null {
|
|
338
|
+
if (resolvedUrl.startsWith("file:")) {
|
|
339
|
+
return fileURLToPath(resolvedUrl)
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (isAbsolute(resolvedUrl)) {
|
|
343
|
+
return resolvedUrl
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (resolvedUrl.startsWith("node:")) {
|
|
347
|
+
return null
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// Bun resolver may return non-file URL schemes for certain modules.
|
|
351
|
+
if (resolvedUrl.includes(":")) {
|
|
352
|
+
return null
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const baseDir = dirname(this.packageJsonPath)
|
|
356
|
+
return resolve(baseDir, "node_modules", packageName)
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
private async getPackageJsonFromPackageName(packageName: string): Promise<[string, PackageJson]> {
|
|
360
|
+
const baseDir = dirname(this.packageJsonPath)
|
|
361
|
+
const packagePath = resolve(baseDir, "node_modules", packageName)
|
|
362
|
+
|
|
363
|
+
return await this.getPackageJson(packagePath)
|
|
364
|
+
}
|
|
365
|
+
|
|
313
366
|
private async getPackageJson(basePath: string): Promise<[string, PackageJson]> {
|
|
314
367
|
while (true) {
|
|
315
368
|
const packageJson = await readPackageJSON(basePath)
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Exeteres
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|