@lightdash/cli 2.606.7 → 2.606.8
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/.tsbuildinfo.build +1 -1
- package/dist/handlers/ordinary/harness.mocks.d.ts +1 -5
- package/dist/handlers/ordinary/harness.mocks.d.ts.map +1 -1
- package/dist/handlers/ordinary/harness.mocks.js +4 -30
- package/dist/testing/cliProcess.d.ts +17 -0
- package/dist/testing/cliProcess.d.ts.map +1 -0
- package/dist/testing/cliProcess.js +46 -0
- package/package.json +3 -3
|
@@ -34,9 +34,5 @@ export declare class OrdinaryServer {
|
|
|
34
34
|
export declare const personalConfig: (serverUrl: string) => Config;
|
|
35
35
|
export declare const saveConfig: (home: string, config: Config) => Promise<string>;
|
|
36
36
|
export declare const request: (method: string, url: string, body?: string) => RecordedRequest;
|
|
37
|
-
export declare const runOrdinaryCli: (home: string, args: string[]) => Promise<
|
|
38
|
-
code: number | null;
|
|
39
|
-
stdout: string;
|
|
40
|
-
stderr: string;
|
|
41
|
-
}>;
|
|
37
|
+
export declare const runOrdinaryCli: (home: string, args: string[]) => Promise<import("../../testing/cliProcess").CliProcessResult>;
|
|
42
38
|
//# sourceMappingURL=harness.mocks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harness.mocks.d.ts","sourceRoot":"","sources":["../../../src/handlers/ordinary/harness.mocks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"harness.mocks.d.ts","sourceRoot":"","sources":["../../../src/handlers/ordinary/harness.mocks.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,mBAAmB,EAAE,KAAK,MAAM,EAAE,MAAM,MAAM,CAAC;AAG3E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,MAAM,MAAM,eAAe,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EA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rdinaryCli = exports.request = exports.saveConfig = exports.personalConfig = exports.OrdinaryServer = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const child_process_1 = require("child_process");
|
|
6
5
|
const events_1 = require("events");
|
|
7
6
|
const fs_1 = require("fs");
|
|
8
7
|
const http_1 = require("http");
|
|
9
8
|
const yaml = tslib_1.__importStar(require("js-yaml"));
|
|
10
9
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
-
const
|
|
10
|
+
const cliProcess_1 = require("../../testing/cliProcess");
|
|
12
11
|
class OrdinaryServer {
|
|
13
12
|
received = new events_1.EventEmitter();
|
|
14
13
|
requests = [];
|
|
@@ -141,9 +140,8 @@ const request = (method, url, body = '') => ({
|
|
|
141
140
|
exports.request = request;
|
|
142
141
|
const runOrdinaryCli = async (home, args) => {
|
|
143
142
|
const entry = path_1.default.join(home, 'ordinary-entry.cjs');
|
|
144
|
-
const analytics = path_1.default.
|
|
145
|
-
const
|
|
146
|
-
await fs_1.promises.writeFile(entry, `const { LightdashAnalytics } = require(${JSON.stringify(analytics)}); LightdashAnalytics.track = async () => {}; LightdashAnalytics.identify = async () => {}; require(${JSON.stringify(index)});`);
|
|
143
|
+
const analytics = path_1.default.join(path_1.default.dirname(cliProcess_1.compiledCliEntry), 'analytics/analytics.js');
|
|
144
|
+
await fs_1.promises.writeFile(entry, `const { LightdashAnalytics } = require(${JSON.stringify(analytics)}); LightdashAnalytics.track = async () => {}; LightdashAnalytics.identify = async () => {}; require(${JSON.stringify(cliProcess_1.compiledCliEntry)});`);
|
|
147
145
|
const env = {
|
|
148
146
|
...process.env,
|
|
149
147
|
HOME: home,
|
|
@@ -151,30 +149,6 @@ const runOrdinaryCli = async (home, args) => {
|
|
|
151
149
|
FORCE_COLOR: '0',
|
|
152
150
|
CI: 'true',
|
|
153
151
|
};
|
|
154
|
-
|
|
155
|
-
env,
|
|
156
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
157
|
-
});
|
|
158
|
-
let timer;
|
|
159
|
-
try {
|
|
160
|
-
return await new Promise((resolve, reject) => {
|
|
161
|
-
timer = (0, timers_1.setTimeout)(() => reject(new Error('Ordinary CLI child timed out after 20s')), 20_000);
|
|
162
|
-
let stdout = '';
|
|
163
|
-
let stderr = '';
|
|
164
|
-
child.stdout.on('data', (chunk) => {
|
|
165
|
-
stdout += String(chunk);
|
|
166
|
-
});
|
|
167
|
-
child.stderr.on('data', (chunk) => {
|
|
168
|
-
stderr += String(chunk);
|
|
169
|
-
});
|
|
170
|
-
child.on('error', reject);
|
|
171
|
-
child.on('close', (code) => resolve({ code, stdout, stderr }));
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
finally {
|
|
175
|
-
(0, timers_1.clearTimeout)(timer);
|
|
176
|
-
if (child.exitCode === null && child.signalCode === null)
|
|
177
|
-
child.kill('SIGKILL');
|
|
178
|
-
}
|
|
152
|
+
return (0, cliProcess_1.runCliProcess)({ args, env, entry, timeoutMs: 20_000 });
|
|
179
153
|
};
|
|
180
154
|
exports.runOrdinaryCli = runOrdinaryCli;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const compiledCliEntry: string;
|
|
2
|
+
export type CliProcessResult = {
|
|
3
|
+
code: number | null;
|
|
4
|
+
stdout: string;
|
|
5
|
+
stderr: string;
|
|
6
|
+
};
|
|
7
|
+
type CliProcessOptions = {
|
|
8
|
+
args: string[];
|
|
9
|
+
env: NodeJS.ProcessEnv;
|
|
10
|
+
cwd?: string;
|
|
11
|
+
entry?: string;
|
|
12
|
+
preload?: string;
|
|
13
|
+
timeoutMs?: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const runCliProcess: ({ args, env, cwd, entry, preload, timeoutMs, }: CliProcessOptions) => Promise<CliProcessResult>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=cliProcess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliProcess.d.ts","sourceRoot":"","sources":["../../src/testing/cliProcess.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB,QAAiD,CAAC;AAI/E,MAAM,MAAM,gBAAgB,GAAG;IAC3B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACrB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,aAAa,mDAOvB,iBAAiB,KAAG,OAAO,CAAC,gBAAgB,CA0CzC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runCliProcess = exports.compiledCliEntry = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const os_1 = require("os");
|
|
7
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
+
const timers_1 = require("timers");
|
|
9
|
+
exports.compiledCliEntry = path_1.default.resolve(__dirname, '../../dist/index.js');
|
|
10
|
+
// Shared across spawns so each child skips recompiling the CLI's module graph.
|
|
11
|
+
const compileCache = path_1.default.join((0, os_1.tmpdir)(), 'lightdash-cli-test-compile-cache');
|
|
12
|
+
const runCliProcess = ({ args, env, cwd, entry = exports.compiledCliEntry, preload, timeoutMs = 30_000, }) => new Promise((resolve, reject) => {
|
|
13
|
+
const child = (0, child_process_1.spawn)(process.execPath, [
|
|
14
|
+
...(preload === undefined ? [] : ['--require', preload]),
|
|
15
|
+
...(entry.endsWith('.ts')
|
|
16
|
+
? ['--import', require.resolve('tsx')]
|
|
17
|
+
: []),
|
|
18
|
+
entry,
|
|
19
|
+
...args,
|
|
20
|
+
], {
|
|
21
|
+
cwd,
|
|
22
|
+
env: { ...env, NODE_COMPILE_CACHE: compileCache },
|
|
23
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
24
|
+
});
|
|
25
|
+
let stdout = '';
|
|
26
|
+
let stderr = '';
|
|
27
|
+
const timeout = (0, timers_1.setTimeout)(() => {
|
|
28
|
+
child.kill('SIGKILL');
|
|
29
|
+
reject(new Error(`CLI child timed out after ${timeoutMs}ms: ${args.join(' ')}`));
|
|
30
|
+
}, timeoutMs);
|
|
31
|
+
child.stdout.on('data', (data) => {
|
|
32
|
+
stdout += String(data);
|
|
33
|
+
});
|
|
34
|
+
child.stderr.on('data', (data) => {
|
|
35
|
+
stderr += String(data);
|
|
36
|
+
});
|
|
37
|
+
child.on('error', (error) => {
|
|
38
|
+
(0, timers_1.clearTimeout)(timeout);
|
|
39
|
+
reject(error);
|
|
40
|
+
});
|
|
41
|
+
child.on('close', (code) => {
|
|
42
|
+
(0, timers_1.clearTimeout)(timeout);
|
|
43
|
+
resolve({ code, stdout, stderr });
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
exports.runCliProcess = runCliProcess;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash/cli",
|
|
3
|
-
"version": "2.606.
|
|
3
|
+
"version": "2.606.8",
|
|
4
4
|
"description": "Lightdash CLI tool",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"@actions/core": "1.11.1",
|
|
23
23
|
"@aws-sdk/credential-providers": "3.995.0",
|
|
24
24
|
"@casl/ability": "6.8.0",
|
|
25
|
-
"@lightdash/common": "2.606.
|
|
26
|
-
"@lightdash/warehouses": "2.606.
|
|
25
|
+
"@lightdash/common": "2.606.8",
|
|
26
|
+
"@lightdash/warehouses": "2.606.8",
|
|
27
27
|
"@sidvind/better-ajv-errors": "7.0.0",
|
|
28
28
|
"@types/columnify": "1.5.1",
|
|
29
29
|
"ajv": "8.18.0",
|