license-cop 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/lib/config/find-config.js +2 -3
- package/src/lib/config/find-config.js.map +1 -1
- package/src/lib/config/parent-resolutions/http.js +4 -0
- package/src/lib/config/parent-resolutions/http.js.map +1 -1
- package/src/lib/config/parsers/json5.d.ts +1 -0
- package/src/lib/config/parsers/json5.js +13 -0
- package/src/lib/config/parsers/json5.js.map +1 -0
package/package.json
CHANGED
|
@@ -6,9 +6,8 @@ Object.defineProperty(exports, "findConfig", {
|
|
|
6
6
|
enumerable: true,
|
|
7
7
|
get: ()=>findConfig
|
|
8
8
|
});
|
|
9
|
-
const _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default;
|
|
10
9
|
const _cosmiconfig = require("cosmiconfig");
|
|
11
|
-
const _json5 =
|
|
10
|
+
const _json5 = require("./parsers/json5");
|
|
12
11
|
// cspell:disable-next-line
|
|
13
12
|
const moduleNames = [
|
|
14
13
|
"licenses",
|
|
@@ -42,7 +41,7 @@ const searchPlaces = [
|
|
|
42
41
|
for (const moduleName of moduleNames){
|
|
43
42
|
searchPlaces.push(...generateSearchPlaces(moduleName));
|
|
44
43
|
}
|
|
45
|
-
const json5Loader = (
|
|
44
|
+
const json5Loader = (_filepath, content)=>Promise.resolve((0, _json5.json5Parse)(content));
|
|
46
45
|
const findConfig = async (rootDir)=>{
|
|
47
46
|
const options = {
|
|
48
47
|
stopDir: rootDir,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/license-cop/src/lib/config/find-config.ts"],"sourcesContent":["import { cosmiconfig, Options as CosmiconfigOptions, Loader } from \"cosmiconfig\";\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/license-cop/src/lib/config/find-config.ts"],"sourcesContent":["import { cosmiconfig, Options as CosmiconfigOptions, Loader } from \"cosmiconfig\";\nimport { json5Parse } from \"./parsers/json5\";\n\n// cspell:disable-next-line\nconst moduleNames = [\"licenses\", \"licences\", \"licensesrc\", \"licencesrc\"];\n\nconst generateSearchPlaces = (moduleName: string): string[] => [\n `.${moduleName}`,\n `.${moduleName}.json`,\n `.${moduleName}.jsonc`,\n `.${moduleName}.json5`,\n `.${moduleName}.yaml`,\n `.${moduleName}.yml`,\n `.${moduleName}.js`,\n `.${moduleName}.cjs`,\n `.config/${moduleName}`,\n `.config/${moduleName}.json`,\n `.config/${moduleName}.jsonc`,\n `.config/${moduleName}.json5`,\n `.config/${moduleName}.yaml`,\n `.config/${moduleName}.yml`,\n `.config/${moduleName}.js`,\n `.config/${moduleName}.cjs`,\n `${moduleName}.config.js`,\n `${moduleName}.config.cjs`\n];\n\nconst searchPlaces: string[] = [\"package.json\"];\n\nfor (const moduleName of moduleNames) {\n searchPlaces.push(...generateSearchPlaces(moduleName));\n}\n\nconst json5Loader: Loader = (_filepath, content) => Promise.resolve(json5Parse(content));\n\nexport const findConfig = async (rootDir: string): Promise<unknown> => {\n const options: CosmiconfigOptions = {\n stopDir: rootDir,\n searchPlaces,\n loaders: {\n \".json\": json5Loader,\n \".jsonc\": json5Loader,\n \".json5\": json5Loader\n }\n };\n\n const explorer = cosmiconfig(\"licensecop\", options);\n\n const result = await explorer.search(rootDir);\n\n if (!result?.config) {\n throw new Error(\"No config file found\");\n }\n\n return result.config;\n};\n"],"names":["findConfig","moduleNames","generateSearchPlaces","moduleName","searchPlaces","push","json5Loader","_filepath","content","Promise","resolve","json5Parse","rootDir","options","stopDir","loaders","explorer","cosmiconfig","result","search","config","Error"],"mappings":";;;;+BAmCaA;;aAAAA;;6BAnCsD;uBACxC;AAE3B,2BAA2B;AAC3B,MAAMC,cAAc;IAAC;IAAY;IAAY;IAAc;CAAa;AAExE,MAAMC,uBAAuB,CAACC,aAAiC;QAC7D,CAAC,CAAC,EAAEA,WAAW,CAAC;QAChB,CAAC,CAAC,EAAEA,WAAW,KAAK,CAAC;QAC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C;IAED,OAAOH,OAAOE,MAAM;AACtB"}
|
|
@@ -8,8 +8,12 @@ Object.defineProperty(exports, "httpResolution", {
|
|
|
8
8
|
});
|
|
9
9
|
const _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default;
|
|
10
10
|
const _axios = /*#__PURE__*/ _interopRequireDefault(require("axios"));
|
|
11
|
+
const _json5 = require("../parsers/json5");
|
|
11
12
|
const httpResolution = async (url)=>{
|
|
12
13
|
const response = await _axios.default.get(url);
|
|
14
|
+
if (typeof response.data === "string") {
|
|
15
|
+
return await (0, _json5.json5Parse)(response.data);
|
|
16
|
+
}
|
|
13
17
|
return response.data;
|
|
14
18
|
};
|
|
15
19
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/license-cop/src/lib/config/parent-resolutions/http.ts"],"sourcesContent":["import axios from \"axios\";\n\nexport const httpResolution = async (url: string) => {\n const response = await axios.get(url);\n return response.data;\n};\n"],"names":["httpResolution","url","response","axios","get","data"],"mappings":";;;;+
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/license-cop/src/lib/config/parent-resolutions/http.ts"],"sourcesContent":["import axios from \"axios\";\nimport { json5Parse } from \"../parsers/json5\";\n\nexport const httpResolution = async (url: string) => {\n const response = await axios.get(url);\n\n if (typeof response.data === \"string\") {\n return await json5Parse(response.data);\n }\n\n return response.data;\n};\n"],"names":["httpResolution","url","response","axios","get","data","json5Parse"],"mappings":";;;;+BAGaA;;aAAAA;;;4DAHK;uBACS;AAEpB,MAAMA,iBAAiB,OAAOC,MAAgB;IACnD,MAAMC,WAAW,MAAMC,cAAK,CAACC,GAAG,CAACH;IAEjC,IAAI,OAAOC,SAASG,IAAI,KAAK,UAAU;QACrC,OAAO,MAAMC,IAAAA,iBAAU,EAACJ,SAASG,IAAI;IACvC,CAAC;IAED,OAAOH,SAASG,IAAI;AACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const json5Parse: <T>(content: string) => T;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "json5Parse", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>json5Parse
|
|
8
|
+
});
|
|
9
|
+
const _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default;
|
|
10
|
+
const _json5 = /*#__PURE__*/ _interopRequireDefault(require("json5"));
|
|
11
|
+
const json5Parse = (content)=>_json5.default.parse(content);
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=json5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/license-cop/src/lib/config/parsers/json5.ts"],"sourcesContent":["import JSON5 from \"json5\";\n\nexport const json5Parse = <T>(content: string): T => JSON5.parse<T>(content);\n"],"names":["json5Parse","content","JSON5","parse"],"mappings":";;;;+BAEaA;;aAAAA;;;4DAFK;AAEX,MAAMA,aAAa,CAAIC,UAAuBC,cAAK,CAACC,KAAK,CAAIF"}
|