@servicetitan/startup-utils 40.3.0 → 41.0.0
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/get-version-mismatches.d.ts +2 -2
- package/dist/get-version-mismatches.d.ts.map +1 -1
- package/dist/get-version-mismatches.js +4 -4
- package/dist/get-version-mismatches.js.map +1 -1
- package/dist/node/configuration.d.ts +37 -0
- package/dist/node/configuration.d.ts.map +1 -0
- package/dist/node/configuration.js +93 -0
- package/dist/node/configuration.js.map +1 -0
- package/dist/node/get-folders.d.ts +8 -0
- package/dist/node/get-folders.d.ts.map +1 -0
- package/dist/node/get-folders.js +33 -0
- package/dist/node/get-folders.js.map +1 -0
- package/dist/node/get-package-data.d.ts +9 -0
- package/dist/node/get-package-data.d.ts.map +1 -0
- package/dist/node/get-package-data.js +27 -0
- package/dist/node/get-package-data.js.map +1 -0
- package/dist/node/get-package-name.d.ts +3 -0
- package/dist/node/get-package-name.d.ts.map +1 -0
- package/dist/node/get-package-name.js +24 -0
- package/dist/node/get-package-name.js.map +1 -0
- package/dist/node/index.d.ts +9 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +26 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/log.d.ts +10 -0
- package/dist/node/log.d.ts.map +1 -0
- package/dist/node/log.js +64 -0
- package/dist/node/log.js.map +1 -0
- package/dist/node/read-json.d.ts +3 -0
- package/dist/node/read-json.d.ts.map +1 -0
- package/dist/node/read-json.js +36 -0
- package/dist/node/read-json.js.map +1 -0
- package/dist/node/types.d.ts +2 -0
- package/dist/node/types.d.ts.map +1 -0
- package/dist/node/types.js +6 -0
- package/dist/node/types.js.map +1 -0
- package/dist/node/warn-deprecated-shared-dependencies.d.ts +3 -0
- package/dist/node/warn-deprecated-shared-dependencies.d.ts.map +1 -0
- package/dist/node/warn-deprecated-shared-dependencies.js +27 -0
- package/dist/node/warn-deprecated-shared-dependencies.js.map +1 -0
- package/dist/types.d.ts +6 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -1
- package/src/get-version-mismatches.ts +5 -5
- package/src/node/configuration.ts +115 -0
- package/src/node/get-folders.ts +25 -0
- package/src/node/get-package-data.ts +24 -0
- package/src/node/get-package-name.ts +12 -0
- package/src/node/index.ts +8 -0
- package/src/node/log.ts +39 -0
- package/src/node/read-json.ts +13 -0
- package/src/node/types.ts +1 -0
- package/src/node/warn-deprecated-shared-dependencies.ts +29 -0
- package/src/types.ts +8 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const getVersionMismatches: (
|
|
1
|
+
import { SharedDependencies } from './types';
|
|
2
|
+
export declare const getVersionMismatches: (hostSharedDependencies: SharedDependencies, dependencies: Record<string, string>, sharedDependencies: Record<string, string>) => Record<string, {
|
|
3
3
|
host: string;
|
|
4
4
|
package: string;
|
|
5
5
|
}> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-version-mismatches.d.ts","sourceRoot":"","sources":["../src/get-version-mismatches.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"get-version-mismatches.d.ts","sourceRoot":"","sources":["../src/get-version-mismatches.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,eAAO,MAAM,oBAAoB,GAC7B,wBAAwB,kBAAkB,EAC1C,cAAc,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,oBAAoB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;UAeT,MAAM;aAAW,MAAM;cAc3D,CAAC"}
|
|
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "getVersionMismatches", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _iscompatible = require("./is-compatible");
|
|
12
|
-
const getVersionMismatches = (
|
|
13
|
-
const mismatch = Object.entries(
|
|
12
|
+
const getVersionMismatches = (hostSharedDependencies, dependencies, sharedDependencies)=>{
|
|
13
|
+
const mismatch = Object.entries(hostSharedDependencies).reduce((result, [dependency, { version: hostVersion }])=>{
|
|
14
14
|
const packageVersion = dependencies[dependency];
|
|
15
15
|
if (packageVersion && !!sharedDependencies[dependency] && !(0, _iscompatible.isCompatible)(hostVersion, packageVersion)) {
|
|
16
16
|
result[dependency] = {
|
|
@@ -22,12 +22,12 @@ const getVersionMismatches = (exposedDependencies, dependencies, sharedDependenc
|
|
|
22
22
|
}, {});
|
|
23
23
|
for (const [dependency, variable] of Object.entries(sharedDependencies)){
|
|
24
24
|
const packageVersion = dependencies[dependency];
|
|
25
|
-
if (!
|
|
25
|
+
if (!hostSharedDependencies[dependency]) {
|
|
26
26
|
mismatch[dependency] = {
|
|
27
27
|
host: 'missing',
|
|
28
28
|
package: packageVersion
|
|
29
29
|
};
|
|
30
|
-
} else if (
|
|
30
|
+
} else if (hostSharedDependencies[dependency].variable !== variable) {
|
|
31
31
|
mismatch[dependency] = {
|
|
32
32
|
host: 'wrong global variable',
|
|
33
33
|
package: packageVersion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/get-version-mismatches.ts"],"sourcesContent":["import { isCompatible } from './is-compatible';\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/get-version-mismatches.ts"],"sourcesContent":["import { isCompatible } from './is-compatible';\nimport { SharedDependencies } from './types';\n\nexport const getVersionMismatches = (\n hostSharedDependencies: SharedDependencies,\n dependencies: Record<string, string>,\n sharedDependencies: Record<string, string>\n) => {\n const mismatch = Object.entries(hostSharedDependencies).reduce(\n (result, [dependency, { version: hostVersion }]) => {\n const packageVersion = dependencies[dependency];\n if (\n packageVersion &&\n !!sharedDependencies[dependency] &&\n !isCompatible(hostVersion, packageVersion)\n ) {\n result[dependency] = { host: hostVersion, package: packageVersion };\n }\n\n return result;\n },\n {} as Record<string, { host: string; package: string }>\n );\n\n for (const [dependency, variable] of Object.entries(sharedDependencies)) {\n const packageVersion = dependencies[dependency];\n\n if (!hostSharedDependencies[dependency]) {\n mismatch[dependency] = { host: 'missing', package: packageVersion };\n } else if (hostSharedDependencies[dependency].variable !== variable) {\n mismatch[dependency] = { host: 'wrong global variable', package: packageVersion };\n }\n }\n\n return Object.keys(mismatch).length ? mismatch : undefined;\n};\n"],"names":["getVersionMismatches","hostSharedDependencies","dependencies","sharedDependencies","mismatch","Object","entries","reduce","result","dependency","version","hostVersion","packageVersion","isCompatible","host","package","variable","keys","length","undefined"],"mappings":";;;;+BAGaA;;;eAAAA;;;8BAHgB;AAGtB,MAAMA,uBAAuB,CAChCC,wBACAC,cACAC;IAEA,MAAMC,WAAWC,OAAOC,OAAO,CAACL,wBAAwBM,MAAM,CAC1D,CAACC,QAAQ,CAACC,YAAY,EAAEC,SAASC,WAAW,EAAE,CAAC;QAC3C,MAAMC,iBAAiBV,YAAY,CAACO,WAAW;QAC/C,IACIG,kBACA,CAAC,CAACT,kBAAkB,CAACM,WAAW,IAChC,CAACI,IAAAA,0BAAY,EAACF,aAAaC,iBAC7B;YACEJ,MAAM,CAACC,WAAW,GAAG;gBAAEK,MAAMH;gBAAaI,SAASH;YAAe;QACtE;QAEA,OAAOJ;IACX,GACA,CAAC;IAGL,KAAK,MAAM,CAACC,YAAYO,SAAS,IAAIX,OAAOC,OAAO,CAACH,oBAAqB;QACrE,MAAMS,iBAAiBV,YAAY,CAACO,WAAW;QAE/C,IAAI,CAACR,sBAAsB,CAACQ,WAAW,EAAE;YACrCL,QAAQ,CAACK,WAAW,GAAG;gBAAEK,MAAM;gBAAWC,SAASH;YAAe;QACtE,OAAO,IAAIX,sBAAsB,CAACQ,WAAW,CAACO,QAAQ,KAAKA,UAAU;YACjEZ,QAAQ,CAACK,WAAW,GAAG;gBAAEK,MAAM;gBAAyBC,SAASH;YAAe;QACpF;IACJ;IAEA,OAAOP,OAAOY,IAAI,CAACb,UAAUc,MAAM,GAAGd,WAAWe;AACrD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { LocationOrJson } from './types';
|
|
2
|
+
export interface WebComponentBranchConfigs {
|
|
3
|
+
publishTag?: string;
|
|
4
|
+
uploadSourcemaps?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface WebComponentOptions {
|
|
7
|
+
legacyRoot?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* mapping of git branches to configs.
|
|
10
|
+
* Used to separate configs (ex publish tag) depending on current branch
|
|
11
|
+
*/
|
|
12
|
+
branches?: Record<string, WebComponentBranchConfigs>;
|
|
13
|
+
}
|
|
14
|
+
export interface SharedDependenciesConfiguration {
|
|
15
|
+
'expose-shared-dependencies'?: boolean;
|
|
16
|
+
'shared-dependencies'?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
export interface CliConfiguration extends SharedDependenciesConfiguration {
|
|
19
|
+
'provide-shared-dependencies'?: boolean;
|
|
20
|
+
'web-component'?: boolean | string | WebComponentOptions;
|
|
21
|
+
'webpack'?: false | SharedDependenciesConfiguration;
|
|
22
|
+
}
|
|
23
|
+
export declare function getConfiguration<T extends object = CliConfiguration>(locationOrJson?: LocationOrJson): T;
|
|
24
|
+
export declare function getConfigurationSafe<T extends object = CliConfiguration>(locationOrJson?: LocationOrJson): T;
|
|
25
|
+
export declare function getWebpackConfiguration<T extends object = SharedDependenciesConfiguration>(locationOrJson?: LocationOrJson): T;
|
|
26
|
+
export declare function getWebComponentConfiguration(locationOrJson?: LocationOrJson): WebComponentOptions | undefined;
|
|
27
|
+
export declare function getSharedDependencies(locationOrJson?: LocationOrJson): Record<string, string> | undefined;
|
|
28
|
+
type ProvideSharedDependenciesConfig = Pick<CliConfiguration, 'expose-shared-dependencies' | 'provide-shared-dependencies'>;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the "provide-shared-dependencies" setting from a cli configuration,
|
|
31
|
+
* falling back to the deprecated "expose-shared-dependencies" key.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getProvideSharedDependencies(config: ProvideSharedDependenciesConfig): boolean | undefined;
|
|
34
|
+
export declare function isProvidingSharedDependencies(locationOrJson?: LocationOrJson): boolean;
|
|
35
|
+
export declare function isWebComponent(locationOrJson?: LocationOrJson): boolean;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=configuration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/node/configuration.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,yBAAyB;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,mBAAmB;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;CACxD;AAED,MAAM,WAAW,+BAA+B;IAC5C,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClD;AAGD,MAAM,WAAW,gBAAiB,SAAQ,+BAA+B;IACrE,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,mBAAmB,CAAC;IACzD,SAAS,CAAC,EAAE,KAAK,GAAG,+BAA+B,CAAC;CACvD;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,gBAAgB,EAChE,cAAc,GAAE,cAAqB,GACtC,CAAC,CAMH;AAED,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,GAAG,gBAAgB,EACpE,cAAc,GAAE,cAAqB,GACtC,CAAC,CAMH;AAED,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,GAAG,+BAA+B,EACtF,cAAc,CAAC,EAAE,cAAc,GAChC,CAAC,CAGH;AAED,wBAAgB,4BAA4B,CACxC,cAAc,GAAE,cAAqB,GACtC,mBAAmB,GAAG,SAAS,CAsBjC;AAED,wBAAgB,qBAAqB,CAAC,cAAc,CAAC,EAAE,cAAc,sCAKpE;AAED,KAAK,+BAA+B,GAAG,IAAI,CACvC,gBAAgB,EAChB,4BAA4B,GAAG,6BAA6B,CAC/D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,+BAA+B,uBAEnF;AAED,wBAAgB,6BAA6B,CAAC,cAAc,CAAC,EAAE,cAAc,WAK5E;AAED,wBAAgB,cAAc,CAAC,cAAc,GAAE,cAAqB,WAEnE"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get getConfiguration () {
|
|
13
|
+
return getConfiguration;
|
|
14
|
+
},
|
|
15
|
+
get getConfigurationSafe () {
|
|
16
|
+
return getConfigurationSafe;
|
|
17
|
+
},
|
|
18
|
+
get getProvideSharedDependencies () {
|
|
19
|
+
return getProvideSharedDependencies;
|
|
20
|
+
},
|
|
21
|
+
get getSharedDependencies () {
|
|
22
|
+
return getSharedDependencies;
|
|
23
|
+
},
|
|
24
|
+
get getWebComponentConfiguration () {
|
|
25
|
+
return getWebComponentConfiguration;
|
|
26
|
+
},
|
|
27
|
+
get getWebpackConfiguration () {
|
|
28
|
+
return getWebpackConfiguration;
|
|
29
|
+
},
|
|
30
|
+
get isProvidingSharedDependencies () {
|
|
31
|
+
return isProvidingSharedDependencies;
|
|
32
|
+
},
|
|
33
|
+
get isWebComponent () {
|
|
34
|
+
return isWebComponent;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
38
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
39
|
+
const _log = require("./log");
|
|
40
|
+
const _readjson = require("./read-json");
|
|
41
|
+
function _interop_require_default(obj) {
|
|
42
|
+
return obj && obj.__esModule ? obj : {
|
|
43
|
+
default: obj
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function getConfiguration(locationOrJson = './') {
|
|
47
|
+
var _json_cli;
|
|
48
|
+
const json = typeof locationOrJson === 'string' ? (0, _readjson.readJson)(_path.default.join(locationOrJson, 'package.json')) : locationOrJson;
|
|
49
|
+
return (_json_cli = json.cli) !== null && _json_cli !== void 0 ? _json_cli : {};
|
|
50
|
+
}
|
|
51
|
+
function getConfigurationSafe(locationOrJson = './') {
|
|
52
|
+
var _ref;
|
|
53
|
+
const json = typeof locationOrJson === 'string' ? (0, _readjson.readJsonSafe)(_path.default.join(locationOrJson, 'package.json')) : locationOrJson;
|
|
54
|
+
return (_ref = json === null || json === void 0 ? void 0 : json.cli) !== null && _ref !== void 0 ? _ref : {};
|
|
55
|
+
}
|
|
56
|
+
function getWebpackConfiguration(locationOrJson) {
|
|
57
|
+
const { webpack } = getConfiguration(locationOrJson);
|
|
58
|
+
return typeof webpack === 'object' ? webpack : {};
|
|
59
|
+
}
|
|
60
|
+
function getWebComponentConfiguration(locationOrJson = './') {
|
|
61
|
+
const config = getConfigurationSafe(locationOrJson)['web-component'];
|
|
62
|
+
if (config === true) {
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
if (typeof config === 'object') {
|
|
66
|
+
return config;
|
|
67
|
+
}
|
|
68
|
+
if (typeof config === 'string') {
|
|
69
|
+
const configPath = _path.default.resolve(typeof locationOrJson === 'string' ? _path.default.join(locationOrJson, config) : config);
|
|
70
|
+
if (_fs.default.existsSync(configPath)) {
|
|
71
|
+
return require(_path.default.resolve(configPath));
|
|
72
|
+
}
|
|
73
|
+
_log.log.warning(`could not find web-component configuration: "${config}"`);
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function getSharedDependencies(locationOrJson) {
|
|
78
|
+
var _getConfiguration_shareddependencies;
|
|
79
|
+
return (_getConfiguration_shareddependencies = getConfiguration(locationOrJson)['shared-dependencies']) !== null && _getConfiguration_shareddependencies !== void 0 ? _getConfiguration_shareddependencies : getWebpackConfiguration(locationOrJson)['shared-dependencies'];
|
|
80
|
+
}
|
|
81
|
+
function getProvideSharedDependencies(config) {
|
|
82
|
+
var _config_provideshareddependencies;
|
|
83
|
+
return (_config_provideshareddependencies = config['provide-shared-dependencies']) !== null && _config_provideshareddependencies !== void 0 ? _config_provideshareddependencies : config['expose-shared-dependencies'];
|
|
84
|
+
}
|
|
85
|
+
function isProvidingSharedDependencies(locationOrJson) {
|
|
86
|
+
var _getProvideSharedDependencies;
|
|
87
|
+
return ((_getProvideSharedDependencies = getProvideSharedDependencies(getConfiguration(locationOrJson))) !== null && _getProvideSharedDependencies !== void 0 ? _getProvideSharedDependencies : getWebpackConfiguration(locationOrJson)['expose-shared-dependencies']) === true;
|
|
88
|
+
}
|
|
89
|
+
function isWebComponent(locationOrJson = './') {
|
|
90
|
+
return !!getWebComponentConfiguration(locationOrJson);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/node/configuration.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { log } from './log';\nimport { readJson, readJsonSafe } from './read-json';\nimport { LocationOrJson } from './types';\n\nexport interface WebComponentBranchConfigs {\n publishTag?: string;\n uploadSourcemaps?: boolean;\n}\n\nexport interface WebComponentOptions {\n legacyRoot?: boolean;\n /**\n * mapping of git branches to configs.\n * Used to separate configs (ex publish tag) depending on current branch\n */\n branches?: Record<string, WebComponentBranchConfigs>;\n}\n\nexport interface SharedDependenciesConfiguration {\n 'expose-shared-dependencies'?: boolean;\n 'shared-dependencies'?: Record<string, string>;\n}\n\n/* The subset of the package.json `cli` configuration that these helpers read. */\nexport interface CliConfiguration extends SharedDependenciesConfiguration {\n 'provide-shared-dependencies'?: boolean;\n 'web-component'?: boolean | string | WebComponentOptions;\n 'webpack'?: false | SharedDependenciesConfiguration;\n}\n\nexport function getConfiguration<T extends object = CliConfiguration>(\n locationOrJson: LocationOrJson = './'\n): T {\n const json =\n typeof locationOrJson === 'string'\n ? readJson(path.join(locationOrJson, 'package.json'))\n : locationOrJson;\n return json.cli ?? {};\n}\n\nexport function getConfigurationSafe<T extends object = CliConfiguration>(\n locationOrJson: LocationOrJson = './'\n): T {\n const json =\n typeof locationOrJson === 'string'\n ? readJsonSafe(path.join(locationOrJson, 'package.json'))\n : locationOrJson;\n return json?.cli ?? {};\n}\n\nexport function getWebpackConfiguration<T extends object = SharedDependenciesConfiguration>(\n locationOrJson?: LocationOrJson\n): T {\n const { webpack } = getConfiguration<{ webpack?: false | T }>(locationOrJson);\n return typeof webpack === 'object' ? webpack : ({} as T);\n}\n\nexport function getWebComponentConfiguration(\n locationOrJson: LocationOrJson = './'\n): WebComponentOptions | undefined {\n const config = getConfigurationSafe(locationOrJson)['web-component'];\n\n if (config === true) {\n return {};\n }\n\n if (typeof config === 'object') {\n return config;\n }\n\n if (typeof config === 'string') {\n const configPath = path.resolve(\n typeof locationOrJson === 'string' ? path.join(locationOrJson, config) : config\n );\n if (fs.existsSync(configPath)) {\n return require(path.resolve(configPath));\n }\n log.warning(`could not find web-component configuration: \"${config}\"`);\n\n return undefined;\n }\n}\n\nexport function getSharedDependencies(locationOrJson?: LocationOrJson) {\n return (\n getConfiguration(locationOrJson)['shared-dependencies'] ??\n getWebpackConfiguration(locationOrJson)['shared-dependencies']\n );\n}\n\ntype ProvideSharedDependenciesConfig = Pick<\n CliConfiguration,\n 'expose-shared-dependencies' | 'provide-shared-dependencies'\n>;\n\n/**\n * Returns the \"provide-shared-dependencies\" setting from a cli configuration,\n * falling back to the deprecated \"expose-shared-dependencies\" key.\n */\nexport function getProvideSharedDependencies(config: ProvideSharedDependenciesConfig) {\n return config['provide-shared-dependencies'] ?? config['expose-shared-dependencies'];\n}\n\nexport function isProvidingSharedDependencies(locationOrJson?: LocationOrJson) {\n return (\n (getProvideSharedDependencies(getConfiguration(locationOrJson)) ??\n getWebpackConfiguration(locationOrJson)['expose-shared-dependencies']) === true\n );\n}\n\nexport function isWebComponent(locationOrJson: LocationOrJson = './') {\n return !!getWebComponentConfiguration(locationOrJson);\n}\n"],"names":["getConfiguration","getConfigurationSafe","getProvideSharedDependencies","getSharedDependencies","getWebComponentConfiguration","getWebpackConfiguration","isProvidingSharedDependencies","isWebComponent","locationOrJson","json","readJson","path","join","cli","readJsonSafe","webpack","config","configPath","resolve","fs","existsSync","require","log","warning","undefined"],"mappings":";;;;;;;;;;;QAgCgBA;eAAAA;;QAUAC;eAAAA;;QA2DAC;eAAAA;;QAhBAC;eAAAA;;QA1BAC;eAAAA;;QAPAC;eAAAA;;QAqDAC;eAAAA;;QAOAC;eAAAA;;;2DAhHD;6DACE;qBACG;0BACmB;;;;;;AA6BhC,SAASP,iBACZQ,iBAAiC,IAAI;QAM9BC;IAJP,MAAMA,OACF,OAAOD,mBAAmB,WACpBE,IAAAA,kBAAQ,EAACC,aAAI,CAACC,IAAI,CAACJ,gBAAgB,mBACnCA;IACV,QAAOC,YAAAA,KAAKI,GAAG,cAARJ,uBAAAA,YAAY,CAAC;AACxB;AAEO,SAASR,qBACZO,iBAAiC,IAAI;;IAErC,MAAMC,OACF,OAAOD,mBAAmB,WACpBM,IAAAA,sBAAY,EAACH,aAAI,CAACC,IAAI,CAACJ,gBAAgB,mBACvCA;IACV,eAAOC,iBAAAA,2BAAAA,KAAMI,GAAG,uCAAI,CAAC;AACzB;AAEO,SAASR,wBACZG,cAA+B;IAE/B,MAAM,EAAEO,OAAO,EAAE,GAAGf,iBAA0CQ;IAC9D,OAAO,OAAOO,YAAY,WAAWA,UAAW,CAAC;AACrD;AAEO,SAASX,6BACZI,iBAAiC,IAAI;IAErC,MAAMQ,SAASf,qBAAqBO,eAAe,CAAC,gBAAgB;IAEpE,IAAIQ,WAAW,MAAM;QACjB,OAAO,CAAC;IACZ;IAEA,IAAI,OAAOA,WAAW,UAAU;QAC5B,OAAOA;IACX;IAEA,IAAI,OAAOA,WAAW,UAAU;QAC5B,MAAMC,aAAaN,aAAI,CAACO,OAAO,CAC3B,OAAOV,mBAAmB,WAAWG,aAAI,CAACC,IAAI,CAACJ,gBAAgBQ,UAAUA;QAE7E,IAAIG,WAAE,CAACC,UAAU,CAACH,aAAa;YAC3B,OAAOI,QAAQV,aAAI,CAACO,OAAO,CAACD;QAChC;QACAK,QAAG,CAACC,OAAO,CAAC,CAAC,6CAA6C,EAAEP,OAAO,CAAC,CAAC;QAErE,OAAOQ;IACX;AACJ;AAEO,SAASrB,sBAAsBK,cAA+B;QAE7DR;IADJ,QACIA,uCAAAA,iBAAiBQ,eAAe,CAAC,sBAAsB,cAAvDR,kDAAAA,uCACAK,wBAAwBG,eAAe,CAAC,sBAAsB;AAEtE;AAWO,SAASN,6BAA6Bc,MAAuC;QACzEA;IAAP,QAAOA,oCAAAA,MAAM,CAAC,8BAA8B,cAArCA,+CAAAA,oCAAyCA,MAAM,CAAC,6BAA6B;AACxF;AAEO,SAASV,8BAA8BE,cAA+B;QAEpEN;IADL,OACI,EAACA,gCAAAA,6BAA6BF,iBAAiBQ,8BAA9CN,2CAAAA,gCACGG,wBAAwBG,eAAe,CAAC,6BAA6B,MAAM;AAEvF;AAEO,SAASD,eAAeC,iBAAiC,IAAI;IAChE,OAAO,CAAC,CAACJ,6BAA6BI;AAC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-folders.d.ts","sourceRoot":"","sources":["../../src/node/get-folders.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,SAAO;;;EAkBzC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getFolders", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getFolders;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
12
|
+
const _readjson = require("./read-json");
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function getFolders(location = './') {
|
|
19
|
+
var _readJson_compilerOptions;
|
|
20
|
+
const { rootDir, outDir } = (_readJson_compilerOptions = (0, _readjson.readJson)(_path.default.join(location, 'tsconfig.json')).compilerOptions) !== null && _readJson_compilerOptions !== void 0 ? _readJson_compilerOptions : {};
|
|
21
|
+
if (!rootDir) {
|
|
22
|
+
throw new Error('"compilerOptions.rootDir" must be defined in the "tsconfig.json"!');
|
|
23
|
+
}
|
|
24
|
+
if (!outDir) {
|
|
25
|
+
throw new Error('"compilerOptions.outDir" must be defined in the "tsconfig.json"!');
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
source: rootDir,
|
|
29
|
+
destination: outDir
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=get-folders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/node/get-folders.ts"],"sourcesContent":["import path from 'path';\nimport { readJson } from './read-json';\n\n/**\n * Returns folders of sources and compilation target\n */\nexport function getFolders(location = './') {\n const { rootDir, outDir } =\n readJson<{ compilerOptions: { rootDir?: string; outDir?: string } }>(\n path.join(location, 'tsconfig.json')\n ).compilerOptions ?? {};\n\n if (!rootDir) {\n throw new Error('\"compilerOptions.rootDir\" must be defined in the \"tsconfig.json\"!');\n }\n\n if (!outDir) {\n throw new Error('\"compilerOptions.outDir\" must be defined in the \"tsconfig.json\"!');\n }\n\n return {\n source: rootDir,\n destination: outDir,\n };\n}\n"],"names":["getFolders","location","readJson","rootDir","outDir","path","join","compilerOptions","Error","source","destination"],"mappings":";;;;+BAMgBA;;;eAAAA;;;6DANC;0BACQ;;;;;;AAKlB,SAASA,WAAWC,WAAW,IAAI;QAElCC;IADJ,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAE,IACrBF,4BAAAA,IAAAA,kBAAQ,EACJG,aAAI,CAACC,IAAI,CAACL,UAAU,kBACtBM,eAAe,cAFjBL,uCAAAA,4BAEqB,CAAC;IAE1B,IAAI,CAACC,SAAS;QACV,MAAM,IAAIK,MAAM;IACpB;IAEA,IAAI,CAACJ,QAAQ;QACT,MAAM,IAAII,MAAM;IACpB;IAEA,OAAO;QACHC,QAAQN;QACRO,aAAaN;IACjB;AACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface PackageData {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string;
|
|
4
|
+
dependencies: Record<string, string>;
|
|
5
|
+
sharedDependencies?: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
export declare function getPackageData(): PackageData;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=get-package-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-package-data.d.ts","sourceRoot":"","sources":["../../src/node/get-package-data.ts"],"names":[],"mappings":"AAEA,UAAU,WAAW;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/C;AAED,wBAAgB,cAAc,IAAI,WAAW,CAc5C"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getPackageData", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getPackageData;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _readjson = require("./read-json");
|
|
12
|
+
function getPackageData() {
|
|
13
|
+
var _ref;
|
|
14
|
+
var _packageJson_cli, _packageJson_cli_webpack, _packageJson_cli1;
|
|
15
|
+
const packageJson = (0, _readjson.readJson)('./package.json');
|
|
16
|
+
return {
|
|
17
|
+
name: packageJson.name,
|
|
18
|
+
version: packageJson.version,
|
|
19
|
+
dependencies: {
|
|
20
|
+
...(0, _readjson.readJson)('../../package.json').dependencies,
|
|
21
|
+
...packageJson.dependencies
|
|
22
|
+
},
|
|
23
|
+
sharedDependencies: (_ref = (_packageJson_cli = packageJson.cli) === null || _packageJson_cli === void 0 ? void 0 : _packageJson_cli['shared-dependencies']) !== null && _ref !== void 0 ? _ref : (_packageJson_cli1 = packageJson.cli) === null || _packageJson_cli1 === void 0 ? void 0 : (_packageJson_cli_webpack = _packageJson_cli1.webpack) === null || _packageJson_cli_webpack === void 0 ? void 0 : _packageJson_cli_webpack['shared-dependencies']
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=get-package-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/node/get-package-data.ts"],"sourcesContent":["import { readJson } from './read-json';\n\ninterface PackageData {\n name: string;\n version: string;\n dependencies: Record<string, string>;\n sharedDependencies?: Record<string, string>;\n}\n\nexport function getPackageData(): PackageData {\n const packageJson = readJson('./package.json');\n\n return {\n name: packageJson.name,\n version: packageJson.version,\n dependencies: {\n ...readJson('../../package.json').dependencies,\n ...packageJson.dependencies,\n },\n sharedDependencies:\n packageJson.cli?.['shared-dependencies'] ??\n packageJson.cli?.webpack?.['shared-dependencies'],\n };\n}\n"],"names":["getPackageData","packageJson","readJson","name","version","dependencies","sharedDependencies","cli","webpack"],"mappings":";;;;+BASgBA;;;eAAAA;;;0BATS;AASlB,SAASA;;QAWJC,kBACAA,0BAAAA;IAXR,MAAMA,cAAcC,IAAAA,kBAAQ,EAAC;IAE7B,OAAO;QACHC,MAAMF,YAAYE,IAAI;QACtBC,SAASH,YAAYG,OAAO;QAC5BC,cAAc;YACV,GAAGH,IAAAA,kBAAQ,EAAC,sBAAsBG,YAAY;YAC9C,GAAGJ,YAAYI,YAAY;QAC/B;QACAC,kBAAkB,WACdL,mBAAAA,YAAYM,GAAG,cAAfN,uCAAAA,gBAAiB,CAAC,sBAAsB,wCACxCA,oBAAAA,YAAYM,GAAG,cAAfN,yCAAAA,2BAAAA,kBAAiBO,OAAO,cAAxBP,+CAAAA,wBAA0B,CAAC,sBAAsB;IACzD;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-package-name.d.ts","sourceRoot":"","sources":["../../src/node/get-package-name.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,wBAAgB,cAAc,CAAC,cAAc,GAAE,cAAqB,GAAG,MAAM,CAO5E"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getPackageName", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getPackageName;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
12
|
+
const _readjson = require("./read-json");
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function getPackageName(locationOrJson = './') {
|
|
19
|
+
var _json_name;
|
|
20
|
+
const json = typeof locationOrJson === 'string' ? (0, _readjson.readJson)(_path.default.join(locationOrJson, 'package.json')) : locationOrJson;
|
|
21
|
+
return (_json_name = json.name) !== null && _json_name !== void 0 ? _json_name : '';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=get-package-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/node/get-package-name.ts"],"sourcesContent":["import path from 'path';\nimport { readJson } from './read-json';\nimport { LocationOrJson } from './types';\n\nexport function getPackageName(locationOrJson: LocationOrJson = './'): string {\n const json =\n typeof locationOrJson === 'string'\n ? readJson(path.join(locationOrJson, 'package.json'))\n : locationOrJson;\n\n return json.name ?? '';\n}\n"],"names":["getPackageName","locationOrJson","json","readJson","path","join","name"],"mappings":";;;;+BAIgBA;;;eAAAA;;;6DAJC;0BACQ;;;;;;AAGlB,SAASA,eAAeC,iBAAiC,IAAI;QAMzDC;IALP,MAAMA,OACF,OAAOD,mBAAmB,WACpBE,IAAAA,kBAAQ,EAACC,aAAI,CAACC,IAAI,CAACJ,gBAAgB,mBACnCA;IAEV,QAAOC,aAAAA,KAAKI,IAAI,cAATJ,wBAAAA,aAAa;AACxB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './configuration';
|
|
2
|
+
export * from './get-folders';
|
|
3
|
+
export * from './get-package-data';
|
|
4
|
+
export * from './get-package-name';
|
|
5
|
+
export * from './log';
|
|
6
|
+
export * from './read-json';
|
|
7
|
+
export type * from './types';
|
|
8
|
+
export * from './warn-deprecated-shared-dependencies';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,mBAAmB,SAAS,CAAC;AAC7B,cAAc,uCAAuC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./configuration"), exports);
|
|
6
|
+
_export_star(require("./get-folders"), exports);
|
|
7
|
+
_export_star(require("./get-package-data"), exports);
|
|
8
|
+
_export_star(require("./get-package-name"), exports);
|
|
9
|
+
_export_star(require("./log"), exports);
|
|
10
|
+
_export_star(require("./read-json"), exports);
|
|
11
|
+
_export_star(require("./warn-deprecated-shared-dependencies"), exports);
|
|
12
|
+
function _export_star(from, to) {
|
|
13
|
+
Object.keys(from).forEach(function(k) {
|
|
14
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
15
|
+
Object.defineProperty(to, k, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function() {
|
|
18
|
+
return from[k];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return from;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/node/index.ts"],"sourcesContent":["export * from './configuration';\nexport * from './get-folders';\nexport * from './get-package-data';\nexport * from './get-package-name';\nexport * from './log';\nexport * from './read-json';\nexport type * from './types';\nexport * from './warn-deprecated-shared-dependencies';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBAEA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class Log {
|
|
2
|
+
get timestamp(): string;
|
|
3
|
+
text(...text: string[]): void;
|
|
4
|
+
info(...text: string[]): void;
|
|
5
|
+
success(...text: string[]): void;
|
|
6
|
+
warning(...text: string[]): void;
|
|
7
|
+
error(...text: string[]): void;
|
|
8
|
+
}
|
|
9
|
+
export declare const log: Log;
|
|
10
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/node/log.ts"],"names":[],"mappings":"AAEA,qBAAa,GAAG;IACZ,IAAI,SAAS,WAQZ;IAED,IAAI,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;IAItB,IAAI,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;IAItB,OAAO,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;IAIzB,OAAO,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;IAMzB,KAAK,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;CAK1B;AAED,eAAO,MAAM,GAAG,KAAY,CAAC"}
|
package/dist/node/log.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get Log () {
|
|
13
|
+
return Log;
|
|
14
|
+
},
|
|
15
|
+
get log () {
|
|
16
|
+
return log;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _nodeutil = require("node:util");
|
|
20
|
+
class Log {
|
|
21
|
+
get timestamp() {
|
|
22
|
+
return new Date().toLocaleTimeString(undefined, {
|
|
23
|
+
hour12: false,
|
|
24
|
+
hour: '2-digit',
|
|
25
|
+
minute: '2-digit',
|
|
26
|
+
second: '2-digit',
|
|
27
|
+
fractionalSecondDigits: 3
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
text(...text) {
|
|
31
|
+
process.stdout.write(text.join(' ') + '\n');
|
|
32
|
+
}
|
|
33
|
+
info(...text) {
|
|
34
|
+
process.stdout.write((0, _nodeutil.styleText)([
|
|
35
|
+
'bold',
|
|
36
|
+
'cyan'
|
|
37
|
+
], text.join(' ')) + '\n');
|
|
38
|
+
}
|
|
39
|
+
success(...text) {
|
|
40
|
+
process.stdout.write((0, _nodeutil.styleText)([
|
|
41
|
+
'bold',
|
|
42
|
+
'green'
|
|
43
|
+
], text.join(' ')) + '\n');
|
|
44
|
+
}
|
|
45
|
+
warning(...text) {
|
|
46
|
+
process.stderr.write((0, _nodeutil.styleText)([
|
|
47
|
+
'bold',
|
|
48
|
+
'yellow'
|
|
49
|
+
], text.join(' '), {
|
|
50
|
+
stream: process.stderr
|
|
51
|
+
}) + '\n');
|
|
52
|
+
}
|
|
53
|
+
error(...text) {
|
|
54
|
+
process.stderr.write((0, _nodeutil.styleText)([
|
|
55
|
+
'bold',
|
|
56
|
+
'red'
|
|
57
|
+
], text.join(' '), {
|
|
58
|
+
stream: process.stderr
|
|
59
|
+
}) + '\n');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const log = new Log();
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/node/log.ts"],"sourcesContent":["import { styleText } from 'node:util';\n\nexport class Log {\n get timestamp() {\n return new Date().toLocaleTimeString(undefined, {\n hour12: false,\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n fractionalSecondDigits: 3,\n });\n }\n\n text(...text: string[]) {\n process.stdout.write(text.join(' ') + '\\n');\n }\n\n info(...text: string[]) {\n process.stdout.write(styleText(['bold', 'cyan'], text.join(' ')) + '\\n');\n }\n\n success(...text: string[]) {\n process.stdout.write(styleText(['bold', 'green'], text.join(' ')) + '\\n');\n }\n\n warning(...text: string[]) {\n process.stderr.write(\n styleText(['bold', 'yellow'], text.join(' '), { stream: process.stderr }) + '\\n'\n );\n }\n\n error(...text: string[]) {\n process.stderr.write(\n styleText(['bold', 'red'], text.join(' '), { stream: process.stderr }) + '\\n'\n );\n }\n}\n\nexport const log = new Log();\n"],"names":["Log","log","timestamp","Date","toLocaleTimeString","undefined","hour12","hour","minute","second","fractionalSecondDigits","text","process","stdout","write","join","info","styleText","success","warning","stderr","stream","error"],"mappings":";;;;;;;;;;;QAEaA;eAAAA;;QAoCAC;eAAAA;;;0BAtCa;AAEnB,MAAMD;IACT,IAAIE,YAAY;QACZ,OAAO,IAAIC,OAAOC,kBAAkB,CAACC,WAAW;YAC5CC,QAAQ;YACRC,MAAM;YACNC,QAAQ;YACRC,QAAQ;YACRC,wBAAwB;QAC5B;IACJ;IAEAC,KAAK,GAAGA,IAAc,EAAE;QACpBC,QAAQC,MAAM,CAACC,KAAK,CAACH,KAAKI,IAAI,CAAC,OAAO;IAC1C;IAEAC,KAAK,GAAGL,IAAc,EAAE;QACpBC,QAAQC,MAAM,CAACC,KAAK,CAACG,IAAAA,mBAAS,EAAC;YAAC;YAAQ;SAAO,EAAEN,KAAKI,IAAI,CAAC,QAAQ;IACvE;IAEAG,QAAQ,GAAGP,IAAc,EAAE;QACvBC,QAAQC,MAAM,CAACC,KAAK,CAACG,IAAAA,mBAAS,EAAC;YAAC;YAAQ;SAAQ,EAAEN,KAAKI,IAAI,CAAC,QAAQ;IACxE;IAEAI,QAAQ,GAAGR,IAAc,EAAE;QACvBC,QAAQQ,MAAM,CAACN,KAAK,CAChBG,IAAAA,mBAAS,EAAC;YAAC;YAAQ;SAAS,EAAEN,KAAKI,IAAI,CAAC,MAAM;YAAEM,QAAQT,QAAQQ,MAAM;QAAC,KAAK;IAEpF;IAEAE,MAAM,GAAGX,IAAc,EAAE;QACrBC,QAAQQ,MAAM,CAACN,KAAK,CAChBG,IAAAA,mBAAS,EAAC;YAAC;YAAQ;SAAM,EAAEN,KAAKI,IAAI,CAAC,MAAM;YAAEM,QAAQT,QAAQQ,MAAM;QAAC,KAAK;IAEjF;AACJ;AAEO,MAAMnB,MAAM,IAAID"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-json.d.ts","sourceRoot":"","sources":["../../src/node/read-json.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAEjD;AAED,wBAAgB,YAAY,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAMjE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get readJson () {
|
|
13
|
+
return readJson;
|
|
14
|
+
},
|
|
15
|
+
get readJsonSafe () {
|
|
16
|
+
return readJsonSafe;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
20
|
+
function _interop_require_default(obj) {
|
|
21
|
+
return obj && obj.__esModule ? obj : {
|
|
22
|
+
default: obj
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function readJson(path) {
|
|
26
|
+
return JSON.parse(_fs.default.readFileSync(path, 'utf8'));
|
|
27
|
+
}
|
|
28
|
+
function readJsonSafe(path) {
|
|
29
|
+
try {
|
|
30
|
+
return JSON.parse(_fs.default.readFileSync(path, 'utf8'));
|
|
31
|
+
} catch (unused) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=read-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/node/read-json.ts"],"sourcesContent":["import fs from 'fs';\n\nexport function readJson<T = any>(path: string): T {\n return JSON.parse(fs.readFileSync(path, 'utf8'));\n}\n\nexport function readJsonSafe<T = any>(path: string): T | undefined {\n try {\n return JSON.parse(fs.readFileSync(path, 'utf8'));\n } catch {\n return undefined;\n }\n}\n"],"names":["readJson","readJsonSafe","path","JSON","parse","fs","readFileSync","undefined"],"mappings":";;;;;;;;;;;QAEgBA;eAAAA;;QAIAC;eAAAA;;;2DAND;;;;;;AAER,SAASD,SAAkBE,IAAY;IAC1C,OAAOC,KAAKC,KAAK,CAACC,WAAE,CAACC,YAAY,CAACJ,MAAM;AAC5C;AAEO,SAASD,aAAsBC,IAAY;IAC9C,IAAI;QACA,OAAOC,KAAKC,KAAK,CAACC,WAAE,CAACC,YAAY,CAACJ,MAAM;IAC5C,EAAE,eAAM;QACJ,OAAOK;IACX;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/node/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/node/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warn-deprecated-shared-dependencies.d.ts","sourceRoot":"","sources":["../../src/node/warn-deprecated-shared-dependencies.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,wBAAgB,gCAAgC,CAAC,cAAc,CAAC,EAAE,cAAc,QAwB/E"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "warnDeprecatedSharedDependencies", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return warnDeprecatedSharedDependencies;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _configuration = require("./configuration");
|
|
12
|
+
const _log = require("./log");
|
|
13
|
+
function warnDeprecatedSharedDependencies(locationOrJson) {
|
|
14
|
+
const config = (0, _configuration.getConfiguration)(locationOrJson);
|
|
15
|
+
const webpackConfig = (0, _configuration.getWebpackConfiguration)(locationOrJson);
|
|
16
|
+
if (webpackConfig['shared-dependencies'] !== undefined) {
|
|
17
|
+
_log.log.warning('cli.webpack.shared-dependencies is deprecated. ' + 'Move it to cli.shared-dependencies.');
|
|
18
|
+
}
|
|
19
|
+
if (config['expose-shared-dependencies'] !== undefined) {
|
|
20
|
+
_log.log.warning('cli.expose-shared-dependencies is deprecated. ' + 'Rename it to cli.provide-shared-dependencies.');
|
|
21
|
+
}
|
|
22
|
+
if (webpackConfig['expose-shared-dependencies'] !== undefined) {
|
|
23
|
+
_log.log.warning('cli.webpack.expose-shared-dependencies is deprecated. ' + 'Move it to cli.provide-shared-dependencies.');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=warn-deprecated-shared-dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/node/warn-deprecated-shared-dependencies.ts"],"sourcesContent":["import { getConfiguration, getWebpackConfiguration } from './configuration';\nimport { log } from './log';\nimport type { LocationOrJson } from './types';\n\nexport function warnDeprecatedSharedDependencies(locationOrJson?: LocationOrJson) {\n const config = getConfiguration(locationOrJson);\n const webpackConfig = getWebpackConfiguration(locationOrJson);\n\n if (webpackConfig['shared-dependencies'] !== undefined) {\n log.warning(\n 'cli.webpack.shared-dependencies is deprecated. ' +\n 'Move it to cli.shared-dependencies.'\n );\n }\n\n if (config['expose-shared-dependencies'] !== undefined) {\n log.warning(\n 'cli.expose-shared-dependencies is deprecated. ' +\n 'Rename it to cli.provide-shared-dependencies.'\n );\n }\n\n if (webpackConfig['expose-shared-dependencies'] !== undefined) {\n log.warning(\n 'cli.webpack.expose-shared-dependencies is deprecated. ' +\n 'Move it to cli.provide-shared-dependencies.'\n );\n }\n}\n"],"names":["warnDeprecatedSharedDependencies","locationOrJson","config","getConfiguration","webpackConfig","getWebpackConfiguration","undefined","log","warning"],"mappings":";;;;+BAIgBA;;;eAAAA;;;+BAJ0C;qBACtC;AAGb,SAASA,iCAAiCC,cAA+B;IAC5E,MAAMC,SAASC,IAAAA,+BAAgB,EAACF;IAChC,MAAMG,gBAAgBC,IAAAA,sCAAuB,EAACJ;IAE9C,IAAIG,aAAa,CAAC,sBAAsB,KAAKE,WAAW;QACpDC,QAAG,CAACC,OAAO,CACP,oDACI;IAEZ;IAEA,IAAIN,MAAM,CAAC,6BAA6B,KAAKI,WAAW;QACpDC,QAAG,CAACC,OAAO,CACP,mDACI;IAEZ;IAEA,IAAIJ,aAAa,CAAC,6BAA6B,KAAKE,WAAW;QAC3DC,QAAG,CAACC,OAAO,CACP,2DACI;IAEZ;AACJ"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface SharedDependency {
|
|
2
2
|
version: string;
|
|
3
3
|
variable: string;
|
|
4
4
|
}
|
|
5
|
-
export type
|
|
5
|
+
export type SharedDependencies = Record<string, SharedDependency>;
|
|
6
|
+
/** @deprecated Use `SharedDependency` */
|
|
7
|
+
export type ExposedDependency = SharedDependency;
|
|
8
|
+
/** @deprecated Use `SharedDependencies` */
|
|
9
|
+
export type ExposedDependencies = SharedDependencies;
|
|
6
10
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAElE,yCAAyC;AACzC,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAEjD,2CAA2C;AAC3C,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/startup-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "41.0.0",
|
|
4
4
|
"description": "Reusable utility functions and helpers for uikit packages",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
16
|
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./node": {
|
|
19
|
+
"types": "./dist/node/index.d.ts",
|
|
20
|
+
"default": "./dist/node/index.js"
|
|
17
21
|
}
|
|
18
22
|
},
|
|
19
23
|
"files": [
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { isCompatible } from './is-compatible';
|
|
2
|
-
import {
|
|
2
|
+
import { SharedDependencies } from './types';
|
|
3
3
|
|
|
4
4
|
export const getVersionMismatches = (
|
|
5
|
-
|
|
5
|
+
hostSharedDependencies: SharedDependencies,
|
|
6
6
|
dependencies: Record<string, string>,
|
|
7
7
|
sharedDependencies: Record<string, string>
|
|
8
8
|
) => {
|
|
9
|
-
const mismatch = Object.entries(
|
|
9
|
+
const mismatch = Object.entries(hostSharedDependencies).reduce(
|
|
10
10
|
(result, [dependency, { version: hostVersion }]) => {
|
|
11
11
|
const packageVersion = dependencies[dependency];
|
|
12
12
|
if (
|
|
@@ -25,9 +25,9 @@ export const getVersionMismatches = (
|
|
|
25
25
|
for (const [dependency, variable] of Object.entries(sharedDependencies)) {
|
|
26
26
|
const packageVersion = dependencies[dependency];
|
|
27
27
|
|
|
28
|
-
if (!
|
|
28
|
+
if (!hostSharedDependencies[dependency]) {
|
|
29
29
|
mismatch[dependency] = { host: 'missing', package: packageVersion };
|
|
30
|
-
} else if (
|
|
30
|
+
} else if (hostSharedDependencies[dependency].variable !== variable) {
|
|
31
31
|
mismatch[dependency] = { host: 'wrong global variable', package: packageVersion };
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { log } from './log';
|
|
4
|
+
import { readJson, readJsonSafe } from './read-json';
|
|
5
|
+
import { LocationOrJson } from './types';
|
|
6
|
+
|
|
7
|
+
export interface WebComponentBranchConfigs {
|
|
8
|
+
publishTag?: string;
|
|
9
|
+
uploadSourcemaps?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface WebComponentOptions {
|
|
13
|
+
legacyRoot?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* mapping of git branches to configs.
|
|
16
|
+
* Used to separate configs (ex publish tag) depending on current branch
|
|
17
|
+
*/
|
|
18
|
+
branches?: Record<string, WebComponentBranchConfigs>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SharedDependenciesConfiguration {
|
|
22
|
+
'expose-shared-dependencies'?: boolean;
|
|
23
|
+
'shared-dependencies'?: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* The subset of the package.json `cli` configuration that these helpers read. */
|
|
27
|
+
export interface CliConfiguration extends SharedDependenciesConfiguration {
|
|
28
|
+
'provide-shared-dependencies'?: boolean;
|
|
29
|
+
'web-component'?: boolean | string | WebComponentOptions;
|
|
30
|
+
'webpack'?: false | SharedDependenciesConfiguration;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function getConfiguration<T extends object = CliConfiguration>(
|
|
34
|
+
locationOrJson: LocationOrJson = './'
|
|
35
|
+
): T {
|
|
36
|
+
const json =
|
|
37
|
+
typeof locationOrJson === 'string'
|
|
38
|
+
? readJson(path.join(locationOrJson, 'package.json'))
|
|
39
|
+
: locationOrJson;
|
|
40
|
+
return json.cli ?? {};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getConfigurationSafe<T extends object = CliConfiguration>(
|
|
44
|
+
locationOrJson: LocationOrJson = './'
|
|
45
|
+
): T {
|
|
46
|
+
const json =
|
|
47
|
+
typeof locationOrJson === 'string'
|
|
48
|
+
? readJsonSafe(path.join(locationOrJson, 'package.json'))
|
|
49
|
+
: locationOrJson;
|
|
50
|
+
return json?.cli ?? {};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function getWebpackConfiguration<T extends object = SharedDependenciesConfiguration>(
|
|
54
|
+
locationOrJson?: LocationOrJson
|
|
55
|
+
): T {
|
|
56
|
+
const { webpack } = getConfiguration<{ webpack?: false | T }>(locationOrJson);
|
|
57
|
+
return typeof webpack === 'object' ? webpack : ({} as T);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function getWebComponentConfiguration(
|
|
61
|
+
locationOrJson: LocationOrJson = './'
|
|
62
|
+
): WebComponentOptions | undefined {
|
|
63
|
+
const config = getConfigurationSafe(locationOrJson)['web-component'];
|
|
64
|
+
|
|
65
|
+
if (config === true) {
|
|
66
|
+
return {};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (typeof config === 'object') {
|
|
70
|
+
return config;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (typeof config === 'string') {
|
|
74
|
+
const configPath = path.resolve(
|
|
75
|
+
typeof locationOrJson === 'string' ? path.join(locationOrJson, config) : config
|
|
76
|
+
);
|
|
77
|
+
if (fs.existsSync(configPath)) {
|
|
78
|
+
return require(path.resolve(configPath));
|
|
79
|
+
}
|
|
80
|
+
log.warning(`could not find web-component configuration: "${config}"`);
|
|
81
|
+
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function getSharedDependencies(locationOrJson?: LocationOrJson) {
|
|
87
|
+
return (
|
|
88
|
+
getConfiguration(locationOrJson)['shared-dependencies'] ??
|
|
89
|
+
getWebpackConfiguration(locationOrJson)['shared-dependencies']
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
type ProvideSharedDependenciesConfig = Pick<
|
|
94
|
+
CliConfiguration,
|
|
95
|
+
'expose-shared-dependencies' | 'provide-shared-dependencies'
|
|
96
|
+
>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Returns the "provide-shared-dependencies" setting from a cli configuration,
|
|
100
|
+
* falling back to the deprecated "expose-shared-dependencies" key.
|
|
101
|
+
*/
|
|
102
|
+
export function getProvideSharedDependencies(config: ProvideSharedDependenciesConfig) {
|
|
103
|
+
return config['provide-shared-dependencies'] ?? config['expose-shared-dependencies'];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function isProvidingSharedDependencies(locationOrJson?: LocationOrJson) {
|
|
107
|
+
return (
|
|
108
|
+
(getProvideSharedDependencies(getConfiguration(locationOrJson)) ??
|
|
109
|
+
getWebpackConfiguration(locationOrJson)['expose-shared-dependencies']) === true
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function isWebComponent(locationOrJson: LocationOrJson = './') {
|
|
114
|
+
return !!getWebComponentConfiguration(locationOrJson);
|
|
115
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { readJson } from './read-json';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns folders of sources and compilation target
|
|
6
|
+
*/
|
|
7
|
+
export function getFolders(location = './') {
|
|
8
|
+
const { rootDir, outDir } =
|
|
9
|
+
readJson<{ compilerOptions: { rootDir?: string; outDir?: string } }>(
|
|
10
|
+
path.join(location, 'tsconfig.json')
|
|
11
|
+
).compilerOptions ?? {};
|
|
12
|
+
|
|
13
|
+
if (!rootDir) {
|
|
14
|
+
throw new Error('"compilerOptions.rootDir" must be defined in the "tsconfig.json"!');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (!outDir) {
|
|
18
|
+
throw new Error('"compilerOptions.outDir" must be defined in the "tsconfig.json"!');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
source: rootDir,
|
|
23
|
+
destination: outDir,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { readJson } from './read-json';
|
|
2
|
+
|
|
3
|
+
interface PackageData {
|
|
4
|
+
name: string;
|
|
5
|
+
version: string;
|
|
6
|
+
dependencies: Record<string, string>;
|
|
7
|
+
sharedDependencies?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function getPackageData(): PackageData {
|
|
11
|
+
const packageJson = readJson('./package.json');
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
name: packageJson.name,
|
|
15
|
+
version: packageJson.version,
|
|
16
|
+
dependencies: {
|
|
17
|
+
...readJson('../../package.json').dependencies,
|
|
18
|
+
...packageJson.dependencies,
|
|
19
|
+
},
|
|
20
|
+
sharedDependencies:
|
|
21
|
+
packageJson.cli?.['shared-dependencies'] ??
|
|
22
|
+
packageJson.cli?.webpack?.['shared-dependencies'],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { readJson } from './read-json';
|
|
3
|
+
import { LocationOrJson } from './types';
|
|
4
|
+
|
|
5
|
+
export function getPackageName(locationOrJson: LocationOrJson = './'): string {
|
|
6
|
+
const json =
|
|
7
|
+
typeof locationOrJson === 'string'
|
|
8
|
+
? readJson(path.join(locationOrJson, 'package.json'))
|
|
9
|
+
: locationOrJson;
|
|
10
|
+
|
|
11
|
+
return json.name ?? '';
|
|
12
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './configuration';
|
|
2
|
+
export * from './get-folders';
|
|
3
|
+
export * from './get-package-data';
|
|
4
|
+
export * from './get-package-name';
|
|
5
|
+
export * from './log';
|
|
6
|
+
export * from './read-json';
|
|
7
|
+
export type * from './types';
|
|
8
|
+
export * from './warn-deprecated-shared-dependencies';
|
package/src/node/log.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { styleText } from 'node:util';
|
|
2
|
+
|
|
3
|
+
export class Log {
|
|
4
|
+
get timestamp() {
|
|
5
|
+
return new Date().toLocaleTimeString(undefined, {
|
|
6
|
+
hour12: false,
|
|
7
|
+
hour: '2-digit',
|
|
8
|
+
minute: '2-digit',
|
|
9
|
+
second: '2-digit',
|
|
10
|
+
fractionalSecondDigits: 3,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
text(...text: string[]) {
|
|
15
|
+
process.stdout.write(text.join(' ') + '\n');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
info(...text: string[]) {
|
|
19
|
+
process.stdout.write(styleText(['bold', 'cyan'], text.join(' ')) + '\n');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
success(...text: string[]) {
|
|
23
|
+
process.stdout.write(styleText(['bold', 'green'], text.join(' ')) + '\n');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
warning(...text: string[]) {
|
|
27
|
+
process.stderr.write(
|
|
28
|
+
styleText(['bold', 'yellow'], text.join(' '), { stream: process.stderr }) + '\n'
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
error(...text: string[]) {
|
|
33
|
+
process.stderr.write(
|
|
34
|
+
styleText(['bold', 'red'], text.join(' '), { stream: process.stderr }) + '\n'
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const log = new Log();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
|
|
3
|
+
export function readJson<T = any>(path: string): T {
|
|
4
|
+
return JSON.parse(fs.readFileSync(path, 'utf8'));
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function readJsonSafe<T = any>(path: string): T | undefined {
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(fs.readFileSync(path, 'utf8'));
|
|
10
|
+
} catch {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type LocationOrJson = string | Record<string, any>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getConfiguration, getWebpackConfiguration } from './configuration';
|
|
2
|
+
import { log } from './log';
|
|
3
|
+
import type { LocationOrJson } from './types';
|
|
4
|
+
|
|
5
|
+
export function warnDeprecatedSharedDependencies(locationOrJson?: LocationOrJson) {
|
|
6
|
+
const config = getConfiguration(locationOrJson);
|
|
7
|
+
const webpackConfig = getWebpackConfiguration(locationOrJson);
|
|
8
|
+
|
|
9
|
+
if (webpackConfig['shared-dependencies'] !== undefined) {
|
|
10
|
+
log.warning(
|
|
11
|
+
'cli.webpack.shared-dependencies is deprecated. ' +
|
|
12
|
+
'Move it to cli.shared-dependencies.'
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (config['expose-shared-dependencies'] !== undefined) {
|
|
17
|
+
log.warning(
|
|
18
|
+
'cli.expose-shared-dependencies is deprecated. ' +
|
|
19
|
+
'Rename it to cli.provide-shared-dependencies.'
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (webpackConfig['expose-shared-dependencies'] !== undefined) {
|
|
24
|
+
log.warning(
|
|
25
|
+
'cli.webpack.expose-shared-dependencies is deprecated. ' +
|
|
26
|
+
'Move it to cli.provide-shared-dependencies.'
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface SharedDependency {
|
|
2
2
|
version: string;
|
|
3
3
|
variable: string;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
export type
|
|
6
|
+
export type SharedDependencies = Record<string, SharedDependency>;
|
|
7
|
+
|
|
8
|
+
/** @deprecated Use `SharedDependency` */
|
|
9
|
+
export type ExposedDependency = SharedDependency;
|
|
10
|
+
|
|
11
|
+
/** @deprecated Use `SharedDependencies` */
|
|
12
|
+
export type ExposedDependencies = SharedDependencies;
|