@pgpmjs/core 7.27.1 → 7.27.2
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/core/class/pgpm.js +9 -6
- package/esm/core/class/pgpm.js +9 -6
- package/esm/index.js +1 -0
- package/esm/utils/spawn.js +20 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +4 -2
- package/utils/spawn.d.ts +14 -0
- package/utils/spawn.js +28 -0
package/core/class/pgpm.js
CHANGED
|
@@ -46,7 +46,6 @@ const validators_1 = require("@pgpmjs/ast/files/plan/validators");
|
|
|
46
46
|
const env_1 = require("@pgpmjs/env");
|
|
47
47
|
const logger_1 = require("@pgpmjs/logger");
|
|
48
48
|
const types_1 = require("@pgpmjs/types");
|
|
49
|
-
const child_process_1 = require("child_process");
|
|
50
49
|
const fs_1 = __importDefault(require("fs"));
|
|
51
50
|
const glob = __importStar(require("glob"));
|
|
52
51
|
const os_1 = __importDefault(require("os"));
|
|
@@ -67,6 +66,7 @@ const sync_versions_1 = require("../../packaging/sync-versions");
|
|
|
67
66
|
const deps_1 = require("../../resolution/deps");
|
|
68
67
|
const fs_2 = require("../../utils/fs");
|
|
69
68
|
const glob_1 = require("../../utils/glob");
|
|
69
|
+
const spawn_1 = require("../../utils/spawn");
|
|
70
70
|
const target_utils_1 = require("../../utils/target-utils");
|
|
71
71
|
const template_scaffold_1 = require("../template-scaffold");
|
|
72
72
|
const logger = new logger_1.Logger('pgpm');
|
|
@@ -899,7 +899,13 @@ ${dependencies.length > 0 ? dependencies.map(dep => `-- requires: ${dep}`).join(
|
|
|
899
899
|
const tempDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'pgpm-install-'));
|
|
900
900
|
try {
|
|
901
901
|
process.chdir(tempDir);
|
|
902
|
-
(0,
|
|
902
|
+
(0, spawn_1.spawnSyncChecked)('npm', [
|
|
903
|
+
'install',
|
|
904
|
+
pkgstr,
|
|
905
|
+
'--production',
|
|
906
|
+
'--prefix',
|
|
907
|
+
`./${this.extensionsDir}`
|
|
908
|
+
], {
|
|
903
909
|
stdio: 'inherit'
|
|
904
910
|
});
|
|
905
911
|
const matches = glob.sync((0, glob_1.globPattern)('.', this.extensionsDir, '**/pgpm.plan'));
|
|
@@ -1138,10 +1144,7 @@ ${dependencies.length > 0 ? dependencies.map(dep => `-- requires: ${dep}`).join(
|
|
|
1138
1144
|
const oldVersion = installedVersions[moduleName];
|
|
1139
1145
|
let newVersion = null;
|
|
1140
1146
|
try {
|
|
1141
|
-
const result = (0,
|
|
1142
|
-
encoding: 'utf-8',
|
|
1143
|
-
stdio: ['pipe', 'pipe', 'pipe']
|
|
1144
|
-
}).trim();
|
|
1147
|
+
const result = (0, spawn_1.spawnSyncOutput)('npm', ['view', moduleName, 'version']);
|
|
1145
1148
|
newVersion = result || null;
|
|
1146
1149
|
}
|
|
1147
1150
|
catch {
|
package/esm/core/class/pgpm.js
CHANGED
|
@@ -7,7 +7,6 @@ import { isValidChangeName, isValidTagName, parseReference } from '@pgpmjs/ast/f
|
|
|
7
7
|
import { getExtensionsDir, loadConfigSyncFromDir, resolvePgpmPath, walkUp } from '@pgpmjs/env';
|
|
8
8
|
import { Logger } from '@pgpmjs/logger';
|
|
9
9
|
import { DEFAULT_EXTENSIONS_DIR, errors } from '@pgpmjs/types';
|
|
10
|
-
import { execSync } from 'child_process';
|
|
11
10
|
import fs from 'fs';
|
|
12
11
|
import * as glob from 'glob';
|
|
13
12
|
import os from 'os';
|
|
@@ -28,6 +27,7 @@ import { syncModuleVersions } from '../../packaging/sync-versions';
|
|
|
28
27
|
import { resolveDependencies, resolveExtensionDependencies } from '../../resolution/deps';
|
|
29
28
|
import { movePath } from '../../utils/fs';
|
|
30
29
|
import { globPaths, globPattern, toPosixPath } from '../../utils/glob';
|
|
30
|
+
import { spawnSyncChecked, spawnSyncOutput } from '../../utils/spawn';
|
|
31
31
|
import { parseTarget } from '../../utils/target-utils';
|
|
32
32
|
import { DEFAULT_TEMPLATE_REPO, DEFAULT_TEMPLATE_TOOL_NAME, DEFAULT_TEMPLATE_TTL_MS, scaffoldTemplate } from '../template-scaffold';
|
|
33
33
|
const logger = new Logger('pgpm');
|
|
@@ -860,7 +860,13 @@ ${dependencies.length > 0 ? dependencies.map(dep => `-- requires: ${dep}`).join(
|
|
|
860
860
|
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'pgpm-install-'));
|
|
861
861
|
try {
|
|
862
862
|
process.chdir(tempDir);
|
|
863
|
-
|
|
863
|
+
spawnSyncChecked('npm', [
|
|
864
|
+
'install',
|
|
865
|
+
pkgstr,
|
|
866
|
+
'--production',
|
|
867
|
+
'--prefix',
|
|
868
|
+
`./${this.extensionsDir}`
|
|
869
|
+
], {
|
|
864
870
|
stdio: 'inherit'
|
|
865
871
|
});
|
|
866
872
|
const matches = glob.sync(globPattern('.', this.extensionsDir, '**/pgpm.plan'));
|
|
@@ -1099,10 +1105,7 @@ ${dependencies.length > 0 ? dependencies.map(dep => `-- requires: ${dep}`).join(
|
|
|
1099
1105
|
const oldVersion = installedVersions[moduleName];
|
|
1100
1106
|
let newVersion = null;
|
|
1101
1107
|
try {
|
|
1102
|
-
const result =
|
|
1103
|
-
encoding: 'utf-8',
|
|
1104
|
-
stdio: ['pipe', 'pipe', 'pipe']
|
|
1105
|
-
}).trim();
|
|
1108
|
+
const result = spawnSyncOutput('npm', ['view', moduleName, 'version']);
|
|
1106
1109
|
newVersion = result || null;
|
|
1107
1110
|
}
|
|
1108
1111
|
catch {
|
package/esm/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export * from './packaging/transform';
|
|
|
14
14
|
export * from './rebundle';
|
|
15
15
|
export * from './resolution/deps';
|
|
16
16
|
export * from './resolution/resolve';
|
|
17
|
+
export * from './utils/spawn';
|
|
17
18
|
export * from './workspace/minimal';
|
|
18
19
|
export * from './workspace/paths';
|
|
19
20
|
export * from './workspace/utils';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import spawn from 'cross-spawn';
|
|
2
|
+
export const spawnSyncChecked = (file, args, options = {}) => {
|
|
3
|
+
const result = spawn.sync(file, args, options);
|
|
4
|
+
if (result.error)
|
|
5
|
+
throw result.error;
|
|
6
|
+
if (result.signal) {
|
|
7
|
+
throw new Error(`${file} was terminated by signal ${result.signal}`);
|
|
8
|
+
}
|
|
9
|
+
if (result.status !== 0) {
|
|
10
|
+
const stderr = result.stderr ? String(result.stderr) : '';
|
|
11
|
+
throw new Error(`${file} exited with code ${result.status}${stderr ? `: ${stderr}` : ''}`);
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
};
|
|
15
|
+
/** Run a command and return its stdout, trimmed. */
|
|
16
|
+
export const spawnSyncOutput = (file, args, options = {}) => String(spawnSyncChecked(file, args, {
|
|
17
|
+
...options,
|
|
18
|
+
encoding: 'utf-8',
|
|
19
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
20
|
+
}).stdout ?? '').trim();
|
package/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from './packaging/transform';
|
|
|
14
14
|
export * from './rebundle';
|
|
15
15
|
export * from './resolution/deps';
|
|
16
16
|
export * from './resolution/resolve';
|
|
17
|
+
export * from './utils/spawn';
|
|
17
18
|
export * from './workspace/minimal';
|
|
18
19
|
export * from './workspace/paths';
|
|
19
20
|
export * from './workspace/utils';
|
package/index.js
CHANGED
|
@@ -31,6 +31,7 @@ __exportStar(require("./packaging/transform"), exports);
|
|
|
31
31
|
__exportStar(require("./rebundle"), exports);
|
|
32
32
|
__exportStar(require("./resolution/deps"), exports);
|
|
33
33
|
__exportStar(require("./resolution/resolve"), exports);
|
|
34
|
+
__exportStar(require("./utils/spawn"), exports);
|
|
34
35
|
__exportStar(require("./workspace/minimal"), exports);
|
|
35
36
|
__exportStar(require("./workspace/paths"), exports);
|
|
36
37
|
__exportStar(require("./workspace/utils"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgpmjs/core",
|
|
3
|
-
"version": "7.27.
|
|
3
|
+
"version": "7.27.2",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "PGPM Package and Migration Tools",
|
|
6
6
|
"main": "index.js",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
],
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@pgsql/types": "^18.0.0",
|
|
45
|
+
"@types/cross-spawn": "^6.0.6",
|
|
45
46
|
"@types/pg": "^8.20.4",
|
|
46
47
|
"copyfiles": "^2.4.1",
|
|
47
48
|
"inquirerer": "^4.9.3",
|
|
@@ -57,6 +58,7 @@
|
|
|
57
58
|
"@pgpmjs/slice": "^0.16.1",
|
|
58
59
|
"@pgpmjs/transform": "^0.25.1",
|
|
59
60
|
"@pgpmjs/types": "^2.52.1",
|
|
61
|
+
"cross-spawn": "^7.0.6",
|
|
60
62
|
"csv-to-pg": "^4.12.0",
|
|
61
63
|
"genomic": "^5.6.5",
|
|
62
64
|
"git-changed": "^0.4.0",
|
|
@@ -69,5 +71,5 @@
|
|
|
69
71
|
"pgsql-parser": "^18.2.6",
|
|
70
72
|
"yanse": "^0.2.2"
|
|
71
73
|
},
|
|
72
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "608acc891de5197ad3cb4bfd0babe1050dbec24a"
|
|
73
75
|
}
|
package/utils/spawn.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Synchronous process execution with an argv array instead of a command string.
|
|
3
|
+
*
|
|
4
|
+
* `execFileSync` would do, except that on Windows `npm`/`npx` are `.cmd` shims
|
|
5
|
+
* and those cannot be spawned without a shell (CVE-2024-27980 made it EINVAL),
|
|
6
|
+
* while `shell: true` concatenates argv back into one shell string. `cross-spawn`
|
|
7
|
+
* runs them through `cmd.exe` with each argument escaped individually, so a value
|
|
8
|
+
* containing a space or a shell metacharacter stays a single argument on both
|
|
9
|
+
* platforms.
|
|
10
|
+
*/
|
|
11
|
+
import type { SpawnSyncOptions, SpawnSyncReturns } from 'child_process';
|
|
12
|
+
export declare const spawnSyncChecked: (file: string, args: string[], options?: SpawnSyncOptions) => SpawnSyncReturns<string | Buffer>;
|
|
13
|
+
/** Run a command and return its stdout, trimmed. */
|
|
14
|
+
export declare const spawnSyncOutput: (file: string, args: string[], options?: SpawnSyncOptions) => string;
|
package/utils/spawn.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.spawnSyncOutput = exports.spawnSyncChecked = void 0;
|
|
7
|
+
const cross_spawn_1 = __importDefault(require("cross-spawn"));
|
|
8
|
+
const spawnSyncChecked = (file, args, options = {}) => {
|
|
9
|
+
const result = cross_spawn_1.default.sync(file, args, options);
|
|
10
|
+
if (result.error)
|
|
11
|
+
throw result.error;
|
|
12
|
+
if (result.signal) {
|
|
13
|
+
throw new Error(`${file} was terminated by signal ${result.signal}`);
|
|
14
|
+
}
|
|
15
|
+
if (result.status !== 0) {
|
|
16
|
+
const stderr = result.stderr ? String(result.stderr) : '';
|
|
17
|
+
throw new Error(`${file} exited with code ${result.status}${stderr ? `: ${stderr}` : ''}`);
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
exports.spawnSyncChecked = spawnSyncChecked;
|
|
22
|
+
/** Run a command and return its stdout, trimmed. */
|
|
23
|
+
const spawnSyncOutput = (file, args, options = {}) => String((0, exports.spawnSyncChecked)(file, args, {
|
|
24
|
+
...options,
|
|
25
|
+
encoding: 'utf-8',
|
|
26
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
27
|
+
}).stdout ?? '').trim();
|
|
28
|
+
exports.spawnSyncOutput = spawnSyncOutput;
|