@highstate/cli 0.7.3 → 0.7.4
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/main.js
CHANGED
@@ -10,8 +10,8 @@ import pino, { levels } from 'pino';
|
|
10
10
|
import { readFile, writeFile } from 'node:fs/promises';
|
11
11
|
import { parseAsync } from 'oxc-parser';
|
12
12
|
import { walk } from 'oxc-walker';
|
13
|
-
import { resolve,
|
14
|
-
import { fileURLToPath } from 'node:url';
|
13
|
+
import { resolve, dirname, relative } from 'node:path';
|
14
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
15
15
|
import { sha256 } from 'crypto-hash';
|
16
16
|
import { resolve as resolve$1 } from 'import-meta-resolve';
|
17
17
|
import { pipe, mapValues, mapKeys } from 'remeda';
|
@@ -1185,7 +1185,8 @@ function cleanJsdoc(str) {
|
|
1185
1185
|
}
|
1186
1186
|
|
1187
1187
|
class SourceHashCalculator {
|
1188
|
-
constructor(packageJson, logger) {
|
1188
|
+
constructor(packageJsonPath, packageJson, logger) {
|
1189
|
+
this.packageJsonPath = packageJsonPath;
|
1189
1190
|
this.packageJson = packageJson;
|
1190
1191
|
this.logger = logger;
|
1191
1192
|
}
|
@@ -1247,7 +1248,8 @@ class SourceHashCalculator {
|
|
1247
1248
|
case "npm": {
|
1248
1249
|
let resolvedUrl;
|
1249
1250
|
try {
|
1250
|
-
|
1251
|
+
const baseUrl = pathToFileURL(dirname(this.packageJsonPath));
|
1252
|
+
resolvedUrl = resolve$1(dependency.package, baseUrl.toString());
|
1251
1253
|
} catch (error) {
|
1252
1254
|
this.logger.error(`failed to resolve package "%s"`, dependency.package);
|
1253
1255
|
throw error;
|
@@ -1445,8 +1447,13 @@ class BuildCommand extends Command {
|
|
1445
1447
|
external: ["@pulumi/pulumi"],
|
1446
1448
|
esbuildPlugins: this.library ? [schemaTransformerPlugin] : []
|
1447
1449
|
});
|
1450
|
+
const packageJsonPath = await resolvePackageJSON();
|
1448
1451
|
const upToDatePackageJson = await readPackageJSON();
|
1449
|
-
const sourceHashCalculator = new SourceHashCalculator(
|
1452
|
+
const sourceHashCalculator = new SourceHashCalculator(
|
1453
|
+
packageJsonPath,
|
1454
|
+
upToDatePackageJson,
|
1455
|
+
logger
|
1456
|
+
);
|
1450
1457
|
const distPaths = Object.values(entry).map((value) => value.distPath);
|
1451
1458
|
await sourceHashCalculator.writeHighstateManifest("./dist", distPaths);
|
1452
1459
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@highstate/cli",
|
3
|
-
"version": "0.7.
|
3
|
+
"version": "0.7.4",
|
4
4
|
"description": "The CLI for the Highstate project.",
|
5
5
|
"type": "module",
|
6
6
|
"files": [
|
@@ -18,6 +18,7 @@
|
|
18
18
|
"build": "pkgroll --clean --tsconfig=tsconfig.build.json"
|
19
19
|
},
|
20
20
|
"dependencies": {
|
21
|
+
"@highstate/backend": "^0.7.4",
|
21
22
|
"clipanion": "^4.0.0-rc.4",
|
22
23
|
"consola": "^3.4.0",
|
23
24
|
"crypto-hash": "^3.1.0",
|
@@ -34,8 +35,5 @@
|
|
34
35
|
"devDependencies": {
|
35
36
|
"pkgroll": "^2.5.1"
|
36
37
|
},
|
37
|
-
"
|
38
|
-
"@highstate/backend": "workspace:^0.7.2"
|
39
|
-
},
|
40
|
-
"gitHead": "5cf7cec27262c8fa1d96f6478833b94841459d64"
|
38
|
+
"gitHead": "c482cdf650746f6814122602d65bf5b842a2bc2c"
|
41
39
|
}
|
package/src/commands/build.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Command, Option } from "clipanion"
|
2
|
-
import { readPackageJSON } from "pkg-types"
|
2
|
+
import { readPackageJSON, resolvePackageJSON } from "pkg-types"
|
3
3
|
import { mapKeys, mapValues, pipe } from "remeda"
|
4
4
|
import { build } from "tsup"
|
5
5
|
import { logger, schemaTransformerPlugin, SourceHashCalculator } from "../shared"
|
@@ -84,9 +84,14 @@ export class BuildCommand extends Command {
|
|
84
84
|
esbuildPlugins: this.library ? [schemaTransformerPlugin] : [],
|
85
85
|
})
|
86
86
|
|
87
|
+
const packageJsonPath = await resolvePackageJSON()
|
87
88
|
const upToDatePackageJson = await readPackageJSON()
|
88
89
|
|
89
|
-
const sourceHashCalculator = new SourceHashCalculator(
|
90
|
+
const sourceHashCalculator = new SourceHashCalculator(
|
91
|
+
packageJsonPath,
|
92
|
+
upToDatePackageJson,
|
93
|
+
logger,
|
94
|
+
)
|
90
95
|
const distPaths = Object.values(entry).map(value => value.distPath)
|
91
96
|
|
92
97
|
await sourceHashCalculator.writeHighstateManifest("./dist", distPaths)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { Logger } from "pino"
|
2
2
|
import { dirname, relative, resolve } from "node:path"
|
3
3
|
import { readFile, writeFile } from "node:fs/promises"
|
4
|
-
import { fileURLToPath } from "node:url"
|
4
|
+
import { fileURLToPath, pathToFileURL } from "node:url"
|
5
5
|
import { readPackageJSON, resolvePackageJSON, type PackageJson } from "pkg-types"
|
6
6
|
import { sha256 } from "crypto-hash"
|
7
7
|
import { resolve as importMetaResolve } from "import-meta-resolve"
|
@@ -27,6 +27,7 @@ export class SourceHashCalculator {
|
|
27
27
|
private readonly fileHashes = new Map<string, Promise<string>>()
|
28
28
|
|
29
29
|
constructor(
|
30
|
+
private readonly packageJsonPath: string,
|
30
31
|
private readonly packageJson: PackageJson,
|
31
32
|
private readonly logger: Logger,
|
32
33
|
) {}
|
@@ -102,7 +103,9 @@ export class SourceHashCalculator {
|
|
102
103
|
case "npm": {
|
103
104
|
let resolvedUrl
|
104
105
|
try {
|
105
|
-
|
106
|
+
const baseUrl = pathToFileURL(dirname(this.packageJsonPath))
|
107
|
+
|
108
|
+
resolvedUrl = importMetaResolve(dependency.package, baseUrl.toString())
|
106
109
|
} catch (error) {
|
107
110
|
this.logger.error(`failed to resolve package "%s"`, dependency.package)
|
108
111
|
throw error
|