@posthog/core 1.24.4 → 1.24.5
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/package.json +1 -10
- package/dist/process/cli.d.ts +0 -23
- package/dist/process/cli.d.ts.map +0 -1
- package/dist/process/cli.js +0 -80
- package/dist/process/cli.mjs +0 -40
- package/dist/process/config.d.ts +0 -42
- package/dist/process/config.d.ts.map +0 -1
- package/dist/process/config.js +0 -67
- package/dist/process/config.mjs +0 -33
- package/dist/process/index.d.ts +0 -5
- package/dist/process/index.d.ts.map +0 -1
- package/dist/process/index.js +0 -97
- package/dist/process/index.mjs +0 -5
- package/dist/process/spawn-local.d.ts +0 -7
- package/dist/process/spawn-local.d.ts.map +0 -1
- package/dist/process/spawn-local.js +0 -66
- package/dist/process/spawn-local.mjs +0 -32
- package/dist/process/utils.d.ts +0 -6
- package/dist/process/utils.d.ts.map +0 -1
- package/dist/process/utils.js +0 -85
- package/dist/process/utils.mjs +0 -37
- package/src/process/cli.ts +0 -74
- package/src/process/config.ts +0 -86
- package/src/process/index.ts +0 -4
- package/src/process/spawn-local.ts +0 -45
- package/src/process/utils.spec.ts +0 -11
- package/src/process/utils.ts +0 -51
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/core",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -40,23 +40,14 @@
|
|
|
40
40
|
"types": "./dist/utils/index.d.ts",
|
|
41
41
|
"require": "./dist/utils/index.js",
|
|
42
42
|
"import": "./dist/utils/index.mjs"
|
|
43
|
-
},
|
|
44
|
-
"./process": {
|
|
45
|
-
"types": "./dist/process/index.d.ts",
|
|
46
|
-
"require": "./dist/process/index.js",
|
|
47
|
-
"import": "./dist/process/index.mjs"
|
|
48
43
|
}
|
|
49
44
|
},
|
|
50
45
|
"devDependencies": {
|
|
51
46
|
"@rslib/core": "0.10.6",
|
|
52
|
-
"@types/cross-spawn": "^6.0.6",
|
|
53
47
|
"@types/jest": "^29.5.14",
|
|
54
48
|
"jest": "29.7.0",
|
|
55
49
|
"@posthog-tooling/tsconfig-base": "1.1.1"
|
|
56
50
|
},
|
|
57
|
-
"dependencies": {
|
|
58
|
-
"cross-spawn": "^7.0.6"
|
|
59
|
-
},
|
|
60
51
|
"scripts": {
|
|
61
52
|
"clean": "rimraf dist",
|
|
62
53
|
"lint": "eslint src",
|
package/dist/process/cli.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ResolvedPluginConfig } from './config';
|
|
2
|
-
/**
|
|
3
|
-
* Build CLI arguments for `posthog-cli sourcemap process`.
|
|
4
|
-
*/
|
|
5
|
-
export declare function buildSourcemapCliArgs(config: ResolvedPluginConfig, mode: {
|
|
6
|
-
stdin: true;
|
|
7
|
-
} | {
|
|
8
|
-
directory: string;
|
|
9
|
-
}): string[];
|
|
10
|
-
/**
|
|
11
|
-
* Build environment variables for CLI invocation.
|
|
12
|
-
* Plugin config values override any existing process.env values.
|
|
13
|
-
*/
|
|
14
|
-
export declare function buildCliEnv(config: ResolvedPluginConfig): NodeJS.ProcessEnv;
|
|
15
|
-
/**
|
|
16
|
-
* Spawn the PostHog CLI for sourcemap processing via stdin (file list).
|
|
17
|
-
*/
|
|
18
|
-
export declare function runSourcemapCli(config: ResolvedPluginConfig, options: {
|
|
19
|
-
filePaths: string[];
|
|
20
|
-
} | {
|
|
21
|
-
directory: string;
|
|
22
|
-
}): Promise<void>;
|
|
23
|
-
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/process/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAG/C;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE;IAAE,KAAK,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAC5C,MAAM,EAAE,CA0BV;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAAC,UAAU,CAQ3E;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE;IAAE,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GACvD,OAAO,CAAC,IAAI,CAAC,CAgBf"}
|
package/dist/process/cli.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
runSourcemapCli: ()=>runSourcemapCli,
|
|
28
|
-
buildCliEnv: ()=>buildCliEnv,
|
|
29
|
-
buildSourcemapCliArgs: ()=>buildSourcemapCliArgs
|
|
30
|
-
});
|
|
31
|
-
const external_spawn_local_js_namespaceObject = require("./spawn-local.js");
|
|
32
|
-
function buildSourcemapCliArgs(config, mode) {
|
|
33
|
-
const args = [
|
|
34
|
-
'sourcemap',
|
|
35
|
-
'process'
|
|
36
|
-
];
|
|
37
|
-
if ('stdin' in mode) args.push('--stdin');
|
|
38
|
-
else args.push('--directory', mode.directory);
|
|
39
|
-
if (config.sourcemaps.releaseName) args.push('--release-name', config.sourcemaps.releaseName);
|
|
40
|
-
if (config.sourcemaps.releaseVersion) args.push('--release-version', config.sourcemaps.releaseVersion);
|
|
41
|
-
if (config.sourcemaps.deleteAfterUpload) args.push('--delete-after');
|
|
42
|
-
if (config.sourcemaps.batchSize) args.push('--batch-size', config.sourcemaps.batchSize.toString());
|
|
43
|
-
return args;
|
|
44
|
-
}
|
|
45
|
-
function buildCliEnv(config) {
|
|
46
|
-
return {
|
|
47
|
-
...process.env,
|
|
48
|
-
RUST_LOG: `posthog_cli=${config.logLevel}`,
|
|
49
|
-
POSTHOG_CLI_HOST: config.host,
|
|
50
|
-
POSTHOG_CLI_API_KEY: config.personalApiKey,
|
|
51
|
-
POSTHOG_CLI_PROJECT_ID: config.projectId
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
async function runSourcemapCli(config, options) {
|
|
55
|
-
const mode = 'filePaths' in options ? {
|
|
56
|
-
stdin: true
|
|
57
|
-
} : {
|
|
58
|
-
directory: options.directory
|
|
59
|
-
};
|
|
60
|
-
const args = buildSourcemapCliArgs(config, mode);
|
|
61
|
-
const env = buildCliEnv(config);
|
|
62
|
-
const spawnOptions = {
|
|
63
|
-
cwd: process.cwd(),
|
|
64
|
-
env,
|
|
65
|
-
stdio: 'inherit'
|
|
66
|
-
};
|
|
67
|
-
if ('filePaths' in options) spawnOptions.stdin = options.filePaths.join('\n') + '\n';
|
|
68
|
-
await (0, external_spawn_local_js_namespaceObject.spawnLocal)(config.cliBinaryPath, args, spawnOptions);
|
|
69
|
-
}
|
|
70
|
-
exports.buildCliEnv = __webpack_exports__.buildCliEnv;
|
|
71
|
-
exports.buildSourcemapCliArgs = __webpack_exports__.buildSourcemapCliArgs;
|
|
72
|
-
exports.runSourcemapCli = __webpack_exports__.runSourcemapCli;
|
|
73
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
74
|
-
"buildCliEnv",
|
|
75
|
-
"buildSourcemapCliArgs",
|
|
76
|
-
"runSourcemapCli"
|
|
77
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
78
|
-
Object.defineProperty(exports, '__esModule', {
|
|
79
|
-
value: true
|
|
80
|
-
});
|
package/dist/process/cli.mjs
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { spawnLocal } from "./spawn-local.mjs";
|
|
2
|
-
function buildSourcemapCliArgs(config, mode) {
|
|
3
|
-
const args = [
|
|
4
|
-
'sourcemap',
|
|
5
|
-
'process'
|
|
6
|
-
];
|
|
7
|
-
if ('stdin' in mode) args.push('--stdin');
|
|
8
|
-
else args.push('--directory', mode.directory);
|
|
9
|
-
if (config.sourcemaps.releaseName) args.push('--release-name', config.sourcemaps.releaseName);
|
|
10
|
-
if (config.sourcemaps.releaseVersion) args.push('--release-version', config.sourcemaps.releaseVersion);
|
|
11
|
-
if (config.sourcemaps.deleteAfterUpload) args.push('--delete-after');
|
|
12
|
-
if (config.sourcemaps.batchSize) args.push('--batch-size', config.sourcemaps.batchSize.toString());
|
|
13
|
-
return args;
|
|
14
|
-
}
|
|
15
|
-
function buildCliEnv(config) {
|
|
16
|
-
return {
|
|
17
|
-
...process.env,
|
|
18
|
-
RUST_LOG: `posthog_cli=${config.logLevel}`,
|
|
19
|
-
POSTHOG_CLI_HOST: config.host,
|
|
20
|
-
POSTHOG_CLI_API_KEY: config.personalApiKey,
|
|
21
|
-
POSTHOG_CLI_PROJECT_ID: config.projectId
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
async function runSourcemapCli(config, options) {
|
|
25
|
-
const mode = 'filePaths' in options ? {
|
|
26
|
-
stdin: true
|
|
27
|
-
} : {
|
|
28
|
-
directory: options.directory
|
|
29
|
-
};
|
|
30
|
-
const args = buildSourcemapCliArgs(config, mode);
|
|
31
|
-
const env = buildCliEnv(config);
|
|
32
|
-
const spawnOptions = {
|
|
33
|
-
cwd: process.cwd(),
|
|
34
|
-
env,
|
|
35
|
-
stdio: 'inherit'
|
|
36
|
-
};
|
|
37
|
-
if ('filePaths' in options) spawnOptions.stdin = options.filePaths.join('\n') + '\n';
|
|
38
|
-
await spawnLocal(config.cliBinaryPath, args, spawnOptions);
|
|
39
|
-
}
|
|
40
|
-
export { buildCliEnv, buildSourcemapCliArgs, runSourcemapCli };
|
package/dist/process/config.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
2
|
-
export interface PluginConfig {
|
|
3
|
-
personalApiKey: string;
|
|
4
|
-
/** @deprecated Use projectId instead */
|
|
5
|
-
envId?: string;
|
|
6
|
-
projectId?: string;
|
|
7
|
-
host?: string;
|
|
8
|
-
logLevel?: LogLevel;
|
|
9
|
-
cliBinaryPath?: string;
|
|
10
|
-
sourcemaps?: {
|
|
11
|
-
enabled?: boolean;
|
|
12
|
-
/** @deprecated Use releaseName instead */
|
|
13
|
-
project?: string;
|
|
14
|
-
releaseName?: string;
|
|
15
|
-
/** @deprecated Use releaseVersion instead */
|
|
16
|
-
version?: string;
|
|
17
|
-
releaseVersion?: string;
|
|
18
|
-
deleteAfterUpload?: boolean;
|
|
19
|
-
batchSize?: number;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export interface ResolvedPluginConfig extends Omit<PluginConfig, 'envId' | 'projectId'> {
|
|
23
|
-
projectId?: string;
|
|
24
|
-
host: string;
|
|
25
|
-
logLevel: LogLevel;
|
|
26
|
-
cliBinaryPath: string;
|
|
27
|
-
sourcemaps: {
|
|
28
|
-
enabled: boolean;
|
|
29
|
-
releaseName?: string;
|
|
30
|
-
releaseVersion?: string;
|
|
31
|
-
deleteAfterUpload: boolean;
|
|
32
|
-
batchSize?: number;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export interface ResolveConfigOptions {
|
|
36
|
-
/** Default value for sourcemaps.enabled when not explicitly set. Defaults to true. */
|
|
37
|
-
defaultEnabled?: boolean;
|
|
38
|
-
/** The cwd used for resolving the CLI binary path. Defaults to process.cwd(). */
|
|
39
|
-
cwd?: string;
|
|
40
|
-
}
|
|
41
|
-
export declare function resolveConfig(options: PluginConfig, resolveOptions?: ResolveConfigOptions): ResolvedPluginConfig;
|
|
42
|
-
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/process/config.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;AAErE,MAAM,WAAW,YAAY;IAC3B,cAAc,EAAE,MAAM,CAAA;IACtB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,UAAU,CAAC,EAAE;QACX,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,0CAA0C;QAC1C,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,6CAA6C;QAC7C,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,iBAAiB,CAAC,EAAE,OAAO,CAAA;QAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;CACF;AAED,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,YAAY,EAAE,OAAO,GAAG,WAAW,CAAC;IACrF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,QAAQ,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE;QACV,OAAO,EAAE,OAAO,CAAA;QAChB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,iBAAiB,EAAE,OAAO,CAAA;QAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;CACF;AAED,MAAM,WAAW,oBAAoB;IACnC,sFAAsF;IACtF,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,iFAAiF;IACjF,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,cAAc,CAAC,EAAE,oBAAoB,GAAG,oBAAoB,CAuChH"}
|
package/dist/process/config.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
resolveConfig: ()=>resolveConfig
|
|
28
|
-
});
|
|
29
|
-
const external_utils_js_namespaceObject = require("./utils.js");
|
|
30
|
-
function resolveConfig(options, resolveOptions) {
|
|
31
|
-
const projectId = options.projectId ?? options.envId;
|
|
32
|
-
const host = options.host ?? 'https://us.i.posthog.com';
|
|
33
|
-
const logLevel = options.logLevel ?? 'info';
|
|
34
|
-
const cwd = resolveOptions?.cwd ?? process.cwd();
|
|
35
|
-
const cliBinaryPath = options.cliBinaryPath ?? (0, external_utils_js_namespaceObject.resolveBinaryPath)('posthog-cli', {
|
|
36
|
-
path: process.env.PATH ?? '',
|
|
37
|
-
cwd
|
|
38
|
-
});
|
|
39
|
-
const userSourcemaps = options.sourcemaps ?? {};
|
|
40
|
-
const defaultEnabled = resolveOptions?.defaultEnabled ?? true;
|
|
41
|
-
const enabled = userSourcemaps.enabled ?? defaultEnabled;
|
|
42
|
-
if (enabled) {
|
|
43
|
-
if (!projectId) throw new Error('projectId is required when sourcemaps are enabled (envId is deprecated)');
|
|
44
|
-
if (!options.personalApiKey) throw new Error('personalApiKey is required when sourcemaps are enabled');
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
personalApiKey: options.personalApiKey,
|
|
48
|
-
projectId,
|
|
49
|
-
host,
|
|
50
|
-
logLevel,
|
|
51
|
-
cliBinaryPath,
|
|
52
|
-
sourcemaps: {
|
|
53
|
-
enabled,
|
|
54
|
-
releaseName: userSourcemaps.releaseName ?? userSourcemaps.project,
|
|
55
|
-
releaseVersion: userSourcemaps.releaseVersion ?? userSourcemaps.version,
|
|
56
|
-
deleteAfterUpload: userSourcemaps.deleteAfterUpload ?? true,
|
|
57
|
-
batchSize: userSourcemaps.batchSize
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
exports.resolveConfig = __webpack_exports__.resolveConfig;
|
|
62
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
63
|
-
"resolveConfig"
|
|
64
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
65
|
-
Object.defineProperty(exports, '__esModule', {
|
|
66
|
-
value: true
|
|
67
|
-
});
|
package/dist/process/config.mjs
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { resolveBinaryPath } from "./utils.mjs";
|
|
2
|
-
function resolveConfig(options, resolveOptions) {
|
|
3
|
-
const projectId = options.projectId ?? options.envId;
|
|
4
|
-
const host = options.host ?? 'https://us.i.posthog.com';
|
|
5
|
-
const logLevel = options.logLevel ?? 'info';
|
|
6
|
-
const cwd = resolveOptions?.cwd ?? process.cwd();
|
|
7
|
-
const cliBinaryPath = options.cliBinaryPath ?? resolveBinaryPath('posthog-cli', {
|
|
8
|
-
path: process.env.PATH ?? '',
|
|
9
|
-
cwd
|
|
10
|
-
});
|
|
11
|
-
const userSourcemaps = options.sourcemaps ?? {};
|
|
12
|
-
const defaultEnabled = resolveOptions?.defaultEnabled ?? true;
|
|
13
|
-
const enabled = userSourcemaps.enabled ?? defaultEnabled;
|
|
14
|
-
if (enabled) {
|
|
15
|
-
if (!projectId) throw new Error('projectId is required when sourcemaps are enabled (envId is deprecated)');
|
|
16
|
-
if (!options.personalApiKey) throw new Error('personalApiKey is required when sourcemaps are enabled');
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
personalApiKey: options.personalApiKey,
|
|
20
|
-
projectId,
|
|
21
|
-
host,
|
|
22
|
-
logLevel,
|
|
23
|
-
cliBinaryPath,
|
|
24
|
-
sourcemaps: {
|
|
25
|
-
enabled,
|
|
26
|
-
releaseName: userSourcemaps.releaseName ?? userSourcemaps.project,
|
|
27
|
-
releaseVersion: userSourcemaps.releaseVersion ?? userSourcemaps.version,
|
|
28
|
-
deleteAfterUpload: userSourcemaps.deleteAfterUpload ?? true,
|
|
29
|
-
batchSize: userSourcemaps.batchSize
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export { resolveConfig };
|
package/dist/process/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/process/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,cAAc,UAAU,CAAA;AACxB,cAAc,OAAO,CAAA"}
|
package/dist/process/index.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_modules__ = {
|
|
3
|
-
"./cli": function(module) {
|
|
4
|
-
module.exports = require("./cli.js");
|
|
5
|
-
},
|
|
6
|
-
"./config": function(module) {
|
|
7
|
-
module.exports = require("./config.js");
|
|
8
|
-
},
|
|
9
|
-
"./spawn-local": function(module) {
|
|
10
|
-
module.exports = require("./spawn-local.js");
|
|
11
|
-
},
|
|
12
|
-
"./utils?198b": function(module) {
|
|
13
|
-
module.exports = require("./utils.js");
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
var __webpack_module_cache__ = {};
|
|
17
|
-
function __webpack_require__(moduleId) {
|
|
18
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
19
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
20
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
21
|
-
exports: {}
|
|
22
|
-
};
|
|
23
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
24
|
-
return module.exports;
|
|
25
|
-
}
|
|
26
|
-
(()=>{
|
|
27
|
-
__webpack_require__.n = (module)=>{
|
|
28
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
29
|
-
__webpack_require__.d(getter, {
|
|
30
|
-
a: getter
|
|
31
|
-
});
|
|
32
|
-
return getter;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
(()=>{
|
|
36
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
37
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
get: definition[key]
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
})();
|
|
43
|
-
(()=>{
|
|
44
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
45
|
-
})();
|
|
46
|
-
(()=>{
|
|
47
|
-
__webpack_require__.r = (exports1)=>{
|
|
48
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
49
|
-
value: 'Module'
|
|
50
|
-
});
|
|
51
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
52
|
-
value: true
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
})();
|
|
56
|
-
var __webpack_exports__ = {};
|
|
57
|
-
(()=>{
|
|
58
|
-
__webpack_require__.r(__webpack_exports__);
|
|
59
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
60
|
-
resolveBinaryPath: ()=>_utils__WEBPACK_IMPORTED_MODULE_1__.resolveBinaryPath
|
|
61
|
-
});
|
|
62
|
-
var _spawn_local__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./spawn-local");
|
|
63
|
-
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
64
|
-
for(var __WEBPACK_IMPORT_KEY__ in _spawn_local__WEBPACK_IMPORTED_MODULE_0__)if ([
|
|
65
|
-
"resolveBinaryPath",
|
|
66
|
-
"default"
|
|
67
|
-
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
68
|
-
return _spawn_local__WEBPACK_IMPORTED_MODULE_0__[key];
|
|
69
|
-
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
70
|
-
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
71
|
-
var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./utils?198b");
|
|
72
|
-
var _config__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./config");
|
|
73
|
-
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
74
|
-
for(var __WEBPACK_IMPORT_KEY__ in _config__WEBPACK_IMPORTED_MODULE_2__)if ([
|
|
75
|
-
"resolveBinaryPath",
|
|
76
|
-
"default"
|
|
77
|
-
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
78
|
-
return _config__WEBPACK_IMPORTED_MODULE_2__[key];
|
|
79
|
-
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
80
|
-
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
81
|
-
var _cli__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./cli");
|
|
82
|
-
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
83
|
-
for(var __WEBPACK_IMPORT_KEY__ in _cli__WEBPACK_IMPORTED_MODULE_3__)if ([
|
|
84
|
-
"resolveBinaryPath",
|
|
85
|
-
"default"
|
|
86
|
-
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
87
|
-
return _cli__WEBPACK_IMPORTED_MODULE_3__[key];
|
|
88
|
-
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
89
|
-
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
90
|
-
})();
|
|
91
|
-
exports.resolveBinaryPath = __webpack_exports__.resolveBinaryPath;
|
|
92
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
93
|
-
"resolveBinaryPath"
|
|
94
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
95
|
-
Object.defineProperty(exports, '__esModule', {
|
|
96
|
-
value: true
|
|
97
|
-
});
|
package/dist/process/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spawn-local.d.ts","sourceRoot":"","sources":["../../src/process/spawn-local.ts"],"names":[],"mappings":"AAEA,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;IACP,GAAG,EAAE,MAAM,CAAC,UAAU,CAAA;IACtB,KAAK,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,GACA,OAAO,CAAC,IAAI,CAAC,CAiCf"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
spawnLocal: ()=>spawnLocal
|
|
28
|
-
});
|
|
29
|
-
const external_cross_spawn_namespaceObject = require("cross-spawn");
|
|
30
|
-
async function spawnLocal(executable, args, options) {
|
|
31
|
-
const stdioOption = void 0 !== options.stdin ? [
|
|
32
|
-
'pipe',
|
|
33
|
-
options.stdio,
|
|
34
|
-
options.stdio
|
|
35
|
-
] : options.stdio;
|
|
36
|
-
const child = (0, external_cross_spawn_namespaceObject.spawn)(executable, [
|
|
37
|
-
...args
|
|
38
|
-
], {
|
|
39
|
-
stdio: stdioOption,
|
|
40
|
-
env: options.env,
|
|
41
|
-
cwd: options.cwd
|
|
42
|
-
});
|
|
43
|
-
if (void 0 !== options.stdin && child.stdin) {
|
|
44
|
-
child.stdin.on('error', (err)=>{
|
|
45
|
-
if ('EPIPE' !== err.code) throw err;
|
|
46
|
-
});
|
|
47
|
-
child.stdin.write(options.stdin);
|
|
48
|
-
child.stdin.end();
|
|
49
|
-
}
|
|
50
|
-
await new Promise((resolve, reject)=>{
|
|
51
|
-
child.on('close', (code)=>{
|
|
52
|
-
if (0 === code) resolve();
|
|
53
|
-
else reject(new Error(`Command failed with code ${code}`));
|
|
54
|
-
});
|
|
55
|
-
child.on('error', (error)=>{
|
|
56
|
-
reject(error);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
exports.spawnLocal = __webpack_exports__.spawnLocal;
|
|
61
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
62
|
-
"spawnLocal"
|
|
63
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
64
|
-
Object.defineProperty(exports, '__esModule', {
|
|
65
|
-
value: true
|
|
66
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { spawn } from "cross-spawn";
|
|
2
|
-
async function spawnLocal(executable, args, options) {
|
|
3
|
-
const stdioOption = void 0 !== options.stdin ? [
|
|
4
|
-
'pipe',
|
|
5
|
-
options.stdio,
|
|
6
|
-
options.stdio
|
|
7
|
-
] : options.stdio;
|
|
8
|
-
const child = spawn(executable, [
|
|
9
|
-
...args
|
|
10
|
-
], {
|
|
11
|
-
stdio: stdioOption,
|
|
12
|
-
env: options.env,
|
|
13
|
-
cwd: options.cwd
|
|
14
|
-
});
|
|
15
|
-
if (void 0 !== options.stdin && child.stdin) {
|
|
16
|
-
child.stdin.on('error', (err)=>{
|
|
17
|
-
if ('EPIPE' !== err.code) throw err;
|
|
18
|
-
});
|
|
19
|
-
child.stdin.write(options.stdin);
|
|
20
|
-
child.stdin.end();
|
|
21
|
-
}
|
|
22
|
-
await new Promise((resolve, reject)=>{
|
|
23
|
-
child.on('close', (code)=>{
|
|
24
|
-
if (0 === code) resolve();
|
|
25
|
-
else reject(new Error(`Command failed with code ${code}`));
|
|
26
|
-
});
|
|
27
|
-
child.on('error', (error)=>{
|
|
28
|
-
reject(error);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
export { spawnLocal };
|
package/dist/process/utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/process/utils.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,qBAAqB,GAAI,KAAK,MAAM,KAAG,MAAM,EAQzD,CAAA;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IACP,IAAI,EAAE,MAAM,CAAA;IAEZ,GAAG,EAAE,MAAM,CAAA;CACZ,GACA,MAAM,CAWR"}
|
package/dist/process/utils.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
|
-
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: definition[key]
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
})();
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
-
})();
|
|
23
|
-
(()=>{
|
|
24
|
-
__webpack_require__.r = (exports1)=>{
|
|
25
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
-
value: 'Module'
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
-
value: true
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
|
-
var __webpack_exports__ = {};
|
|
34
|
-
__webpack_require__.r(__webpack_exports__);
|
|
35
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
buildLocalBinaryPaths: ()=>buildLocalBinaryPaths,
|
|
37
|
-
resolveBinaryPath: ()=>resolveBinaryPath
|
|
38
|
-
});
|
|
39
|
-
const external_node_path_namespaceObject = require("node:path");
|
|
40
|
-
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
41
|
-
const external_node_fs_namespaceObject = require("node:fs");
|
|
42
|
-
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
43
|
-
const getLocalPaths = (startPath)=>{
|
|
44
|
-
const paths = [];
|
|
45
|
-
let currentPath = startPath;
|
|
46
|
-
while(true){
|
|
47
|
-
paths.push(currentPath);
|
|
48
|
-
const parentPath = external_node_path_default().resolve(currentPath, '..');
|
|
49
|
-
if (parentPath === currentPath) break;
|
|
50
|
-
currentPath = parentPath;
|
|
51
|
-
}
|
|
52
|
-
return paths;
|
|
53
|
-
};
|
|
54
|
-
const buildLocalBinaryPaths = (cwd)=>{
|
|
55
|
-
const possibleLocations = [
|
|
56
|
-
'node_modules/.bin',
|
|
57
|
-
'node_modules/.pnpm/node_modules/.bin'
|
|
58
|
-
];
|
|
59
|
-
const localPaths = getLocalPaths(external_node_path_default().resolve(cwd)).flatMap((localPath)=>possibleLocations.map((location)=>external_node_path_default().join(localPath, location)));
|
|
60
|
-
return localPaths;
|
|
61
|
-
};
|
|
62
|
-
function resolveBinaryPath(binName, options) {
|
|
63
|
-
const envLocations = options.path.split(external_node_path_default().delimiter);
|
|
64
|
-
const localLocations = buildLocalBinaryPaths(options.cwd);
|
|
65
|
-
const directories = [
|
|
66
|
-
...new Set([
|
|
67
|
-
...localLocations,
|
|
68
|
-
...envLocations
|
|
69
|
-
])
|
|
70
|
-
];
|
|
71
|
-
for (const directory of directories){
|
|
72
|
-
const binaryPath = external_node_path_default().join(directory, binName);
|
|
73
|
-
if (external_node_fs_default().existsSync(binaryPath)) return binaryPath;
|
|
74
|
-
}
|
|
75
|
-
throw new Error(`Binary ${binName} not found`);
|
|
76
|
-
}
|
|
77
|
-
exports.buildLocalBinaryPaths = __webpack_exports__.buildLocalBinaryPaths;
|
|
78
|
-
exports.resolveBinaryPath = __webpack_exports__.resolveBinaryPath;
|
|
79
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
80
|
-
"buildLocalBinaryPaths",
|
|
81
|
-
"resolveBinaryPath"
|
|
82
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
83
|
-
Object.defineProperty(exports, '__esModule', {
|
|
84
|
-
value: true
|
|
85
|
-
});
|
package/dist/process/utils.mjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import node_path from "node:path";
|
|
2
|
-
import node_fs from "node:fs";
|
|
3
|
-
const getLocalPaths = (startPath)=>{
|
|
4
|
-
const paths = [];
|
|
5
|
-
let currentPath = startPath;
|
|
6
|
-
while(true){
|
|
7
|
-
paths.push(currentPath);
|
|
8
|
-
const parentPath = node_path.resolve(currentPath, '..');
|
|
9
|
-
if (parentPath === currentPath) break;
|
|
10
|
-
currentPath = parentPath;
|
|
11
|
-
}
|
|
12
|
-
return paths;
|
|
13
|
-
};
|
|
14
|
-
const buildLocalBinaryPaths = (cwd)=>{
|
|
15
|
-
const possibleLocations = [
|
|
16
|
-
'node_modules/.bin',
|
|
17
|
-
'node_modules/.pnpm/node_modules/.bin'
|
|
18
|
-
];
|
|
19
|
-
const localPaths = getLocalPaths(node_path.resolve(cwd)).flatMap((localPath)=>possibleLocations.map((location)=>node_path.join(localPath, location)));
|
|
20
|
-
return localPaths;
|
|
21
|
-
};
|
|
22
|
-
function resolveBinaryPath(binName, options) {
|
|
23
|
-
const envLocations = options.path.split(node_path.delimiter);
|
|
24
|
-
const localLocations = buildLocalBinaryPaths(options.cwd);
|
|
25
|
-
const directories = [
|
|
26
|
-
...new Set([
|
|
27
|
-
...localLocations,
|
|
28
|
-
...envLocations
|
|
29
|
-
])
|
|
30
|
-
];
|
|
31
|
-
for (const directory of directories){
|
|
32
|
-
const binaryPath = node_path.join(directory, binName);
|
|
33
|
-
if (node_fs.existsSync(binaryPath)) return binaryPath;
|
|
34
|
-
}
|
|
35
|
-
throw new Error(`Binary ${binName} not found`);
|
|
36
|
-
}
|
|
37
|
-
export { buildLocalBinaryPaths, resolveBinaryPath };
|
package/src/process/cli.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { ResolvedPluginConfig } from './config'
|
|
2
|
-
import { spawnLocal } from './spawn-local'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Build CLI arguments for `posthog-cli sourcemap process`.
|
|
6
|
-
*/
|
|
7
|
-
export function buildSourcemapCliArgs(
|
|
8
|
-
config: ResolvedPluginConfig,
|
|
9
|
-
mode: { stdin: true } | { directory: string }
|
|
10
|
-
): string[] {
|
|
11
|
-
const args = ['sourcemap', 'process']
|
|
12
|
-
|
|
13
|
-
if ('stdin' in mode) {
|
|
14
|
-
args.push('--stdin')
|
|
15
|
-
} else {
|
|
16
|
-
args.push('--directory', mode.directory)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (config.sourcemaps.releaseName) {
|
|
20
|
-
args.push('--release-name', config.sourcemaps.releaseName)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (config.sourcemaps.releaseVersion) {
|
|
24
|
-
args.push('--release-version', config.sourcemaps.releaseVersion)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (config.sourcemaps.deleteAfterUpload) {
|
|
28
|
-
args.push('--delete-after')
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (config.sourcemaps.batchSize) {
|
|
32
|
-
args.push('--batch-size', config.sourcemaps.batchSize.toString())
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return args
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Build environment variables for CLI invocation.
|
|
40
|
-
* Plugin config values override any existing process.env values.
|
|
41
|
-
*/
|
|
42
|
-
export function buildCliEnv(config: ResolvedPluginConfig): NodeJS.ProcessEnv {
|
|
43
|
-
return {
|
|
44
|
-
...process.env,
|
|
45
|
-
RUST_LOG: `posthog_cli=${config.logLevel}`,
|
|
46
|
-
POSTHOG_CLI_HOST: config.host,
|
|
47
|
-
POSTHOG_CLI_API_KEY: config.personalApiKey,
|
|
48
|
-
POSTHOG_CLI_PROJECT_ID: config.projectId,
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Spawn the PostHog CLI for sourcemap processing via stdin (file list).
|
|
54
|
-
*/
|
|
55
|
-
export async function runSourcemapCli(
|
|
56
|
-
config: ResolvedPluginConfig,
|
|
57
|
-
options: { filePaths: string[] } | { directory: string }
|
|
58
|
-
): Promise<void> {
|
|
59
|
-
const mode = 'filePaths' in options ? { stdin: true as const } : { directory: options.directory }
|
|
60
|
-
const args = buildSourcemapCliArgs(config, mode)
|
|
61
|
-
const env = buildCliEnv(config)
|
|
62
|
-
|
|
63
|
-
const spawnOptions: Parameters<typeof spawnLocal>[2] = {
|
|
64
|
-
cwd: process.cwd(),
|
|
65
|
-
env,
|
|
66
|
-
stdio: 'inherit',
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if ('filePaths' in options) {
|
|
70
|
-
spawnOptions.stdin = options.filePaths.join('\n') + '\n'
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
await spawnLocal(config.cliBinaryPath, args, spawnOptions)
|
|
74
|
-
}
|
package/src/process/config.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { resolveBinaryPath } from './utils'
|
|
2
|
-
|
|
3
|
-
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent'
|
|
4
|
-
|
|
5
|
-
export interface PluginConfig {
|
|
6
|
-
personalApiKey: string
|
|
7
|
-
/** @deprecated Use projectId instead */
|
|
8
|
-
envId?: string
|
|
9
|
-
projectId?: string
|
|
10
|
-
host?: string
|
|
11
|
-
logLevel?: LogLevel
|
|
12
|
-
cliBinaryPath?: string
|
|
13
|
-
sourcemaps?: {
|
|
14
|
-
enabled?: boolean
|
|
15
|
-
/** @deprecated Use releaseName instead */
|
|
16
|
-
project?: string
|
|
17
|
-
releaseName?: string
|
|
18
|
-
/** @deprecated Use releaseVersion instead */
|
|
19
|
-
version?: string
|
|
20
|
-
releaseVersion?: string
|
|
21
|
-
deleteAfterUpload?: boolean
|
|
22
|
-
batchSize?: number
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface ResolvedPluginConfig extends Omit<PluginConfig, 'envId' | 'projectId'> {
|
|
27
|
-
projectId?: string
|
|
28
|
-
host: string
|
|
29
|
-
logLevel: LogLevel
|
|
30
|
-
cliBinaryPath: string
|
|
31
|
-
sourcemaps: {
|
|
32
|
-
enabled: boolean
|
|
33
|
-
releaseName?: string
|
|
34
|
-
releaseVersion?: string
|
|
35
|
-
deleteAfterUpload: boolean
|
|
36
|
-
batchSize?: number
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface ResolveConfigOptions {
|
|
41
|
-
/** Default value for sourcemaps.enabled when not explicitly set. Defaults to true. */
|
|
42
|
-
defaultEnabled?: boolean
|
|
43
|
-
/** The cwd used for resolving the CLI binary path. Defaults to process.cwd(). */
|
|
44
|
-
cwd?: string
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function resolveConfig(options: PluginConfig, resolveOptions?: ResolveConfigOptions): ResolvedPluginConfig {
|
|
48
|
-
const projectId = options.projectId ?? options.envId
|
|
49
|
-
const host = options.host ?? 'https://us.i.posthog.com'
|
|
50
|
-
const logLevel = options.logLevel ?? 'info'
|
|
51
|
-
const cwd = resolveOptions?.cwd ?? process.cwd()
|
|
52
|
-
const cliBinaryPath =
|
|
53
|
-
options.cliBinaryPath ??
|
|
54
|
-
resolveBinaryPath('posthog-cli', {
|
|
55
|
-
path: process.env.PATH ?? '',
|
|
56
|
-
cwd,
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
const userSourcemaps = options.sourcemaps ?? {}
|
|
60
|
-
const defaultEnabled = resolveOptions?.defaultEnabled ?? true
|
|
61
|
-
const enabled = userSourcemaps.enabled ?? defaultEnabled
|
|
62
|
-
|
|
63
|
-
if (enabled) {
|
|
64
|
-
if (!projectId) {
|
|
65
|
-
throw new Error('projectId is required when sourcemaps are enabled (envId is deprecated)')
|
|
66
|
-
}
|
|
67
|
-
if (!options.personalApiKey) {
|
|
68
|
-
throw new Error('personalApiKey is required when sourcemaps are enabled')
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
personalApiKey: options.personalApiKey,
|
|
74
|
-
projectId,
|
|
75
|
-
host,
|
|
76
|
-
logLevel,
|
|
77
|
-
cliBinaryPath,
|
|
78
|
-
sourcemaps: {
|
|
79
|
-
enabled,
|
|
80
|
-
releaseName: userSourcemaps.releaseName ?? userSourcemaps.project,
|
|
81
|
-
releaseVersion: userSourcemaps.releaseVersion ?? userSourcemaps.version,
|
|
82
|
-
deleteAfterUpload: userSourcemaps.deleteAfterUpload ?? true,
|
|
83
|
-
batchSize: userSourcemaps.batchSize,
|
|
84
|
-
},
|
|
85
|
-
}
|
|
86
|
-
}
|
package/src/process/index.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'cross-spawn'
|
|
2
|
-
|
|
3
|
-
export async function spawnLocal(
|
|
4
|
-
executable: string,
|
|
5
|
-
args: string[],
|
|
6
|
-
options: {
|
|
7
|
-
env: NodeJS.ProcessEnv
|
|
8
|
-
stdio: 'inherit' | 'ignore'
|
|
9
|
-
cwd: string
|
|
10
|
-
stdin?: string
|
|
11
|
-
}
|
|
12
|
-
): Promise<void> {
|
|
13
|
-
const stdioOption = options.stdin !== undefined ? ['pipe' as const, options.stdio, options.stdio] : options.stdio
|
|
14
|
-
|
|
15
|
-
const child = spawn(executable, [...args], {
|
|
16
|
-
stdio: stdioOption,
|
|
17
|
-
env: options.env,
|
|
18
|
-
cwd: options.cwd,
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
if (options.stdin !== undefined && child.stdin) {
|
|
22
|
-
child.stdin.on('error', (err: any) => {
|
|
23
|
-
if (err.code !== 'EPIPE') {
|
|
24
|
-
throw err
|
|
25
|
-
}
|
|
26
|
-
// Swallow EPIPE: child may exit before consuming all stdin
|
|
27
|
-
})
|
|
28
|
-
child.stdin.write(options.stdin)
|
|
29
|
-
child.stdin.end()
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
await new Promise<void>((resolve, reject) => {
|
|
33
|
-
child.on('close', (code) => {
|
|
34
|
-
if (code === 0) {
|
|
35
|
-
resolve()
|
|
36
|
-
} else {
|
|
37
|
-
reject(new Error(`Command failed with code ${code}`))
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
child.on('error', (error) => {
|
|
42
|
-
reject(error)
|
|
43
|
-
})
|
|
44
|
-
})
|
|
45
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { buildLocalBinaryPaths } from './utils'
|
|
2
|
-
|
|
3
|
-
describe('buildLocalBinaryPaths', () => {
|
|
4
|
-
it('generates possible binary locations', () => {
|
|
5
|
-
const cwd = '/home/user'
|
|
6
|
-
const result = buildLocalBinaryPaths(cwd)
|
|
7
|
-
expect(result.includes('/home/user/node_modules/.bin')).toBe(true)
|
|
8
|
-
expect(result.includes('/home/node_modules/.bin')).toBe(true)
|
|
9
|
-
expect(result.includes('/node_modules/.bin')).toBe(true)
|
|
10
|
-
})
|
|
11
|
-
})
|
package/src/process/utils.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
import fs from 'node:fs'
|
|
3
|
-
|
|
4
|
-
const getLocalPaths = (startPath: string): string[] => {
|
|
5
|
-
const paths: string[] = []
|
|
6
|
-
let currentPath = startPath
|
|
7
|
-
|
|
8
|
-
while (true) {
|
|
9
|
-
paths.push(currentPath)
|
|
10
|
-
const parentPath = path.resolve(currentPath, '..')
|
|
11
|
-
|
|
12
|
-
// If we've reached the root directory, stop
|
|
13
|
-
if (parentPath === currentPath) {
|
|
14
|
-
break
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
currentPath = parentPath
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return paths
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const buildLocalBinaryPaths = (cwd: string): string[] => {
|
|
24
|
-
const possibleLocations = ['node_modules/.bin', 'node_modules/.pnpm/node_modules/.bin']
|
|
25
|
-
|
|
26
|
-
const localPaths = getLocalPaths(path.resolve(cwd)).flatMap((localPath: string) =>
|
|
27
|
-
possibleLocations.map((location) => path.join(localPath, location))
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
return localPaths
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function resolveBinaryPath(
|
|
34
|
-
binName: string,
|
|
35
|
-
options: {
|
|
36
|
-
path: string
|
|
37
|
-
// We start traversing the file system tree from this directory and we go up until we find the binary
|
|
38
|
-
cwd: string
|
|
39
|
-
}
|
|
40
|
-
): string {
|
|
41
|
-
const envLocations = options.path.split(path.delimiter)
|
|
42
|
-
const localLocations = buildLocalBinaryPaths(options.cwd)
|
|
43
|
-
const directories = [...new Set([...localLocations, ...envLocations])]
|
|
44
|
-
for (const directory of directories) {
|
|
45
|
-
const binaryPath = path.join(directory, binName)
|
|
46
|
-
if (fs.existsSync(binaryPath)) {
|
|
47
|
-
return binaryPath
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
throw new Error(`Binary ${binName} not found`)
|
|
51
|
-
}
|