license-cop 1.8.0 → 1.9.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/package.json +4 -4
- package/src/lib/cli/commands/init.js +3 -3
- package/src/lib/cli/commands/init.js.map +1 -1
- package/src/lib/config/config-error.js.map +1 -1
- package/src/lib/config/config.d.ts +7 -21
- package/src/lib/config/config.js.map +1 -1
- package/src/lib/config/parent-resolutions/npm.js +3 -3
- package/src/lib/config/parent-resolutions/npm.js.map +1 -1
- package/src/lib/dependency/package-json.d.ts +4 -40
- package/src/lib/dependency/package-json.js +4 -4
- package/src/lib/dependency/package-json.js.map +1 -1
- package/src/lib/dependency-scanning/pnpm.js +1 -1
- package/src/lib/dependency-scanning/pnpm.js.map +1 -1
- package/src/lib/license-cop.js +1 -2
- package/src/lib/license-cop.js.map +1 -1
- package/src/lib/spdx/types/token.js +4 -4
- package/src/lib/spdx/types/token.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "license-cop",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"bin": {
|
|
6
6
|
"license-cop": "./src/bin/license-cop"
|
|
@@ -31,17 +31,17 @@
|
|
|
31
31
|
"oss"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@commander-js/extra-typings": "^
|
|
34
|
+
"@commander-js/extra-typings": "^14.0.0",
|
|
35
35
|
"@npmcli/arborist": "^9.0.0",
|
|
36
36
|
"@pnpm/reviewing.dependencies-hierarchy": "^1001.0.0",
|
|
37
37
|
"axios": "^1.6.0",
|
|
38
|
-
"commander": "^
|
|
38
|
+
"commander": "^14.0.0",
|
|
39
39
|
"compare-versions": "^6.0.0-rc.1",
|
|
40
40
|
"cosmiconfig": "^9.0.0",
|
|
41
41
|
"deepmerge": "^4.3.1",
|
|
42
42
|
"git-filesystem": "^0.0.6",
|
|
43
43
|
"json5": "^2.2.3",
|
|
44
|
-
"zod": "^
|
|
44
|
+
"zod": "^4.0.0"
|
|
45
45
|
},
|
|
46
46
|
"types": "./src/index.d.ts",
|
|
47
47
|
"main": "./src/index.js"
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
function _export(target, all) {
|
|
3
3
|
for(var name in all)Object.defineProperty(target, name, {
|
|
4
4
|
enumerable: true,
|
|
5
|
-
get: all
|
|
5
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
6
6
|
});
|
|
7
7
|
}
|
|
8
8
|
_export(exports, {
|
|
9
|
-
initCommand
|
|
9
|
+
get initCommand () {
|
|
10
10
|
return initCommand;
|
|
11
11
|
},
|
|
12
|
-
initCommandAction
|
|
12
|
+
get initCommandAction () {
|
|
13
13
|
return initCommandAction;
|
|
14
14
|
}
|
|
15
15
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/license-cop/src/lib/cli/commands/init.ts"],"sourcesContent":["import { writeFile } from \"fs/promises\";\nimport { join } from \"path\";\nimport logger from \"../../logger\";\nimport { createCommandWithGlobalOptions } from \"../create-command\";\n\nconst defaultConfig = `{\n \"$schema\": \"https://license-cop.js.org/schema.json\",\n \"licenses\": [\"MIT\", \"ISC\", \"Apache-2.0\"],\n \"packages\": []\n}\n`;\n\nexport const initCommand = createCommandWithGlobalOptions()\n .name(\"init\")\n .description(\"Create a new license-cop configuration file\")\n .action(async options => {\n const { directory } = options;\n\n await initCommandAction(directory);\n });\n\nexport const initCommandAction = async (rootDir: string) => {\n logger.log(\"Setting up a new license-cop config file...\");\n\n const configPath = join(rootDir, \".licenses.json\");\n logger.verbose(`Writing config file to: ${configPath}`);\n await writeFile(configPath, defaultConfig);\n\n logger.log(\"Done!\");\n logger.log(\"Run `npx license-cop` to check your dependencies\");\n};\n"],"names":["initCommand","initCommandAction","defaultConfig","createCommandWithGlobalOptions","name","description","action","options","directory","rootDir","logger","log","configPath","join","verbose","writeFile"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/license-cop/src/lib/cli/commands/init.ts"],"sourcesContent":["import { writeFile } from \"fs/promises\";\nimport { join } from \"path\";\nimport logger from \"../../logger\";\nimport { createCommandWithGlobalOptions } from \"../create-command\";\n\nconst defaultConfig = `{\n \"$schema\": \"https://license-cop.js.org/schema.json\",\n \"licenses\": [\"MIT\", \"ISC\", \"Apache-2.0\"],\n \"packages\": []\n}\n`;\n\nexport const initCommand = createCommandWithGlobalOptions()\n .name(\"init\")\n .description(\"Create a new license-cop configuration file\")\n .action(async options => {\n const { directory } = options;\n\n await initCommandAction(directory);\n });\n\nexport const initCommandAction = async (rootDir: string) => {\n logger.log(\"Setting up a new license-cop config file...\");\n\n const configPath = join(rootDir, \".licenses.json\");\n logger.verbose(`Writing config file to: ${configPath}`);\n await writeFile(configPath, defaultConfig);\n\n logger.log(\"Done!\");\n logger.log(\"Run `npx license-cop` to check your dependencies\");\n};\n"],"names":["initCommand","initCommandAction","defaultConfig","createCommandWithGlobalOptions","name","description","action","options","directory","rootDir","logger","log","configPath","join","verbose","writeFile"],"mappings":";;;;;;;;QAYaA;eAAAA;;QASAC;eAAAA;;;0BArBa;sBACL;wBACF;+BAC4B;AAE/C,MAAMC,gBAAgB,CAAC;;;;;AAKvB,CAAC;AAEM,MAAMF,cAAcG,IAAAA,6CAA8B,IACtDC,IAAI,CAAC,QACLC,WAAW,CAAC,+CACZC,MAAM,CAAC,OAAMC;IACZ,MAAM,EAAEC,SAAS,EAAE,GAAGD;IAEtB,MAAMN,kBAAkBO;AAC1B;AAEK,MAAMP,oBAAoB,OAAOQ;IACtCC,eAAM,CAACC,GAAG,CAAC;IAEX,MAAMC,aAAaC,IAAAA,UAAI,EAACJ,SAAS;IACjCC,eAAM,CAACI,OAAO,CAAC,CAAC,wBAAwB,EAAEF,YAAY;IACtD,MAAMG,IAAAA,mBAAS,EAACH,YAAYV;IAE5BQ,eAAM,CAACC,GAAG,CAAC;IACXD,eAAM,CAACC,GAAG,CAAC;AACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/license-cop/src/lib/config/config-error.ts"],"sourcesContent":["export class ConfigError extends Error {\n constructor(message: string) {\n super(`Config error: ${message}`);\n }\n\n static fromUnknown(e: unknown): ConfigError {\n const message = resolveMessage(e);\n return new ConfigError(message);\n }\n}\n\nconst resolveMessage = (e: unknown): string => {\n if (e instanceof Error) {\n return e.message;\n }\n\n if (typeof e === \"string\") {\n return e;\n }\n\n return \"Unknown error\";\n};\n"],"names":["ConfigError","Error","fromUnknown","e","message","resolveMessage"
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/license-cop/src/lib/config/config-error.ts"],"sourcesContent":["export class ConfigError extends Error {\n constructor(message: string) {\n super(`Config error: ${message}`);\n }\n\n static fromUnknown(e: unknown): ConfigError {\n const message = resolveMessage(e);\n return new ConfigError(message);\n }\n}\n\nconst resolveMessage = (e: unknown): string => {\n if (e instanceof Error) {\n return e.message;\n }\n\n if (typeof e === \"string\") {\n return e;\n }\n\n return \"Unknown error\";\n};\n"],"names":["ConfigError","Error","fromUnknown","e","message","resolveMessage"],"mappings":";+BAAaA;;;eAAAA;;;AAAN,IAAA,AAAMA,cAAN,MAAMA,oBAAoBC;IAK/B,OAAOC,YAAYC,CAAU,EAAe;QAC1C,MAAMC,UAAUC,eAAeF;QAC/B,OAAO,IAAIH,YAAYI;IACzB;IAPA,YAAYA,OAAe,CAAE;QAC3B,KAAK,CAAC,CAAC,cAAc,EAAEA,SAAS;IAClC;AAMF;AAEA,MAAMC,iBAAiB,CAACF;IACtB,IAAIA,aAAaF,OAAO;QACtB,OAAOE,EAAEC,OAAO;IAClB;IAEA,IAAI,OAAOD,MAAM,UAAU;QACzB,OAAOA;IACT;IAEA,OAAO;AACT"}
|
|
@@ -1,39 +1,25 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
declare const configParser: z.
|
|
2
|
+
declare const configParser: z.ZodPipe<z.ZodObject<{
|
|
3
3
|
extends: z.ZodOptional<z.ZodString>;
|
|
4
|
-
licenses: z.ZodOptional<z.ZodArray<z.ZodString
|
|
5
|
-
packages: z.ZodOptional<z.ZodArray<z.ZodString
|
|
4
|
+
licenses: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
5
|
+
packages: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6
6
|
includeDevDependencies: z.ZodOptional<z.ZodBoolean>;
|
|
7
7
|
devDependenciesOnly: z.ZodOptional<z.ZodBoolean>;
|
|
8
8
|
directory: z.ZodOptional<z.ZodString>;
|
|
9
|
-
},
|
|
10
|
-
licenses?: string[] | undefined;
|
|
11
|
-
includeDevDependencies?: boolean | undefined;
|
|
12
|
-
devDependenciesOnly?: boolean | undefined;
|
|
13
|
-
directory?: string | undefined;
|
|
14
|
-
extends?: string | undefined;
|
|
15
|
-
packages?: string[] | undefined;
|
|
16
|
-
}, {
|
|
17
|
-
licenses?: string[] | undefined;
|
|
18
|
-
includeDevDependencies?: boolean | undefined;
|
|
19
|
-
devDependenciesOnly?: boolean | undefined;
|
|
20
|
-
directory?: string | undefined;
|
|
21
|
-
extends?: string | undefined;
|
|
22
|
-
packages?: string[] | undefined;
|
|
23
|
-
}>, {
|
|
9
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
24
10
|
extends: string | undefined;
|
|
25
11
|
licenses: string[];
|
|
26
12
|
packages: string[];
|
|
27
13
|
includeDevDependencies: boolean;
|
|
28
14
|
devDependenciesOnly: boolean;
|
|
29
15
|
}, {
|
|
16
|
+
extends?: string | undefined;
|
|
30
17
|
licenses?: string[] | undefined;
|
|
18
|
+
packages?: string[] | undefined;
|
|
31
19
|
includeDevDependencies?: boolean | undefined;
|
|
32
20
|
devDependenciesOnly?: boolean | undefined;
|
|
33
21
|
directory?: string | undefined;
|
|
34
|
-
|
|
35
|
-
packages?: string[] | undefined;
|
|
36
|
-
}>;
|
|
22
|
+
}>>;
|
|
37
23
|
export type Config = z.infer<typeof configParser>;
|
|
38
24
|
export declare const parseConfig: (config: unknown) => Config;
|
|
39
25
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/license-cop/src/lib/config/config.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { ConfigError } from \"./config-error\";\n\nconst configParser = z\n .object({\n extends: z.string().optional(),\n licenses: z.array(z.string()).optional(),\n packages: z.array(z.string()).optional(),\n includeDevDependencies: z.boolean().optional(),\n devDependenciesOnly: z.boolean().optional(),\n directory: z.string().optional()\n })\n .transform(c => ({\n extends: c.extends,\n licenses: c.licenses ?? [],\n packages: c.packages ?? [],\n includeDevDependencies: c.includeDevDependencies ?? false,\n devDependenciesOnly: c.devDependenciesOnly ?? false\n }));\n\nexport type Config = z.infer<typeof configParser>;\n\nexport const parseConfig = (config: unknown): Config => {\n const parseResult = configParser.safeParse(config);\n\n if (!parseResult.success) {\n throw new ConfigError(parseResult.error.message);\n }\n\n return parseResult.data;\n};\n"],"names":["parseConfig","configParser","z","object","extends","string","optional","licenses","array","packages","includeDevDependencies","boolean","devDependenciesOnly","directory","transform","c","config","parseResult","safeParse","success","ConfigError","error","message","data"],"mappings":";+BAsBaA;;;eAAAA;;;qBAtBK;6BACU;AAE5B,MAAMC,eAAeC,MAAC,CACnBC,MAAM,CAAC;IACNC,SAASF,MAAC,CAACG,MAAM,GAAGC,QAAQ;IAC5BC,UAAUL,MAAC,CAACM,KAAK,CAACN,MAAC,CAACG,MAAM,IAAIC,QAAQ;IACtCG,UAAUP,MAAC,CAACM,KAAK,CAACN,MAAC,CAACG,MAAM,IAAIC,QAAQ;IACtCI,wBAAwBR,MAAC,CAACS,OAAO,GAAGL,QAAQ;IAC5CM,qBAAqBV,MAAC,CAACS,OAAO,GAAGL,QAAQ;IACzCO,WAAWX,MAAC,CAACG,MAAM,GAAGC,QAAQ;AAChC,GACCQ,SAAS,CAACC,CAAAA;QAECA,aACAA,aACcA,2BACHA;WALN;QACfX,SAASW,EAAEX,OAAO;QAClBG,
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/license-cop/src/lib/config/config.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { ConfigError } from \"./config-error\";\n\nconst configParser = z\n .object({\n extends: z.string().optional(),\n licenses: z.array(z.string()).optional(),\n packages: z.array(z.string()).optional(),\n includeDevDependencies: z.boolean().optional(),\n devDependenciesOnly: z.boolean().optional(),\n directory: z.string().optional()\n })\n .transform(c => ({\n extends: c.extends,\n licenses: c.licenses ?? [],\n packages: c.packages ?? [],\n includeDevDependencies: c.includeDevDependencies ?? false,\n devDependenciesOnly: c.devDependenciesOnly ?? false\n }));\n\nexport type Config = z.infer<typeof configParser>;\n\nexport const parseConfig = (config: unknown): Config => {\n const parseResult = configParser.safeParse(config);\n\n if (!parseResult.success) {\n throw new ConfigError(parseResult.error.message);\n }\n\n return parseResult.data;\n};\n"],"names":["parseConfig","configParser","z","object","extends","string","optional","licenses","array","packages","includeDevDependencies","boolean","devDependenciesOnly","directory","transform","c","config","parseResult","safeParse","success","ConfigError","error","message","data"],"mappings":";+BAsBaA;;;eAAAA;;;qBAtBK;6BACU;AAE5B,MAAMC,eAAeC,MAAC,CACnBC,MAAM,CAAC;IACNC,SAASF,MAAC,CAACG,MAAM,GAAGC,QAAQ;IAC5BC,UAAUL,MAAC,CAACM,KAAK,CAACN,MAAC,CAACG,MAAM,IAAIC,QAAQ;IACtCG,UAAUP,MAAC,CAACM,KAAK,CAACN,MAAC,CAACG,MAAM,IAAIC,QAAQ;IACtCI,wBAAwBR,MAAC,CAACS,OAAO,GAAGL,QAAQ;IAC5CM,qBAAqBV,MAAC,CAACS,OAAO,GAAGL,QAAQ;IACzCO,WAAWX,MAAC,CAACG,MAAM,GAAGC,QAAQ;AAChC,GACCQ,SAAS,CAACC,CAAAA;QAECA,aACAA,aACcA,2BACHA;WALN;QACfX,SAASW,EAAEX,OAAO;QAClBG,QAAQ,GAAEQ,cAAAA,EAAER,QAAQ,YAAVQ,cAAc,EAAE;QAC1BN,QAAQ,GAAEM,cAAAA,EAAEN,QAAQ,YAAVM,cAAc,EAAE;QAC1BL,sBAAsB,GAAEK,4BAAAA,EAAEL,sBAAsB,YAAxBK,4BAA4B;QACpDH,mBAAmB,GAAEG,yBAAAA,EAAEH,mBAAmB,YAArBG,yBAAyB;IAChD;;AAIK,MAAMf,cAAc,CAACgB;IAC1B,MAAMC,cAAchB,aAAaiB,SAAS,CAACF;IAE3C,IAAI,CAACC,YAAYE,OAAO,EAAE;QACxB,MAAM,IAAIC,wBAAW,CAACH,YAAYI,KAAK,CAACC,OAAO;IACjD;IAEA,OAAOL,YAAYM,IAAI;AACzB"}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
function _export(target, all) {
|
|
3
3
|
for(var name in all)Object.defineProperty(target, name, {
|
|
4
4
|
enumerable: true,
|
|
5
|
-
get: all
|
|
5
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
6
6
|
});
|
|
7
7
|
}
|
|
8
8
|
_export(exports, {
|
|
9
|
-
nodeModuleExists
|
|
9
|
+
get nodeModuleExists () {
|
|
10
10
|
return nodeModuleExists;
|
|
11
11
|
},
|
|
12
|
-
npmResolution
|
|
12
|
+
get npmResolution () {
|
|
13
13
|
return npmResolution;
|
|
14
14
|
}
|
|
15
15
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/license-cop/src/lib/config/parent-resolutions/npm.ts"],"sourcesContent":["import { stat } from \"fs/promises\";\nimport { join } from \"path\";\nimport logger from \"../../logger\";\nimport { findConfig } from \"../find-config\";\n\nexport const npmResolution = async (packageName: string, rootDir: string) => {\n logger.verbose(`Resolving npm package: ${packageName}`);\n\n const packagePath = getPackagePath(rootDir, packageName);\n return await findConfig(packagePath);\n};\n\nexport const nodeModuleExists = async (packageName: string, rootDir: string) => {\n const packagePath = getPackagePath(rootDir, packageName);\n\n const statResult = await stat(packagePath);\n return statResult.isDirectory();\n};\n\nconst getPackagePath = (rootDir: string, packageName: string) =>\n join(rootDir, \"node_modules\", packageName);\n"],"names":["nodeModuleExists","npmResolution","packageName","rootDir","logger","verbose","packagePath","getPackagePath","findConfig","statResult","stat","isDirectory","join"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/license-cop/src/lib/config/parent-resolutions/npm.ts"],"sourcesContent":["import { stat } from \"fs/promises\";\nimport { join } from \"path\";\nimport logger from \"../../logger\";\nimport { findConfig } from \"../find-config\";\n\nexport const npmResolution = async (packageName: string, rootDir: string) => {\n logger.verbose(`Resolving npm package: ${packageName}`);\n\n const packagePath = getPackagePath(rootDir, packageName);\n return await findConfig(packagePath);\n};\n\nexport const nodeModuleExists = async (packageName: string, rootDir: string) => {\n const packagePath = getPackagePath(rootDir, packageName);\n\n const statResult = await stat(packagePath);\n return statResult.isDirectory();\n};\n\nconst getPackagePath = (rootDir: string, packageName: string) =>\n join(rootDir, \"node_modules\", packageName);\n"],"names":["nodeModuleExists","npmResolution","packageName","rootDir","logger","verbose","packagePath","getPackagePath","findConfig","statResult","stat","isDirectory","join"],"mappings":";;;;;;;;QAYaA;eAAAA;;QAPAC;eAAAA;;;0BALQ;sBACA;wBACF;4BACQ;AAEpB,MAAMA,gBAAgB,OAAOC,aAAqBC;IACvDC,eAAM,CAACC,OAAO,CAAC,CAAC,uBAAuB,EAAEH,aAAa;IAEtD,MAAMI,cAAcC,eAAeJ,SAASD;IAC5C,OAAO,MAAMM,IAAAA,sBAAU,EAACF;AAC1B;AAEO,MAAMN,mBAAmB,OAAOE,aAAqBC;IAC1D,MAAMG,cAAcC,eAAeJ,SAASD;IAE5C,MAAMO,aAAa,MAAMC,IAAAA,cAAI,EAACJ;IAC9B,OAAOG,WAAWE,WAAW;AAC/B;AAEA,MAAMJ,iBAAiB,CAACJ,SAAiBD,cACvCU,IAAAA,UAAI,EAACT,SAAS,gBAAgBD"}
|
|
@@ -2,52 +2,16 @@ import { z } from "zod";
|
|
|
2
2
|
declare const packageJsonValidator: z.ZodObject<{
|
|
3
3
|
name: z.ZodString;
|
|
4
4
|
version: z.ZodString;
|
|
5
|
-
license: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
5
|
+
license: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
6
6
|
type: z.ZodString;
|
|
7
7
|
url: z.ZodOptional<z.ZodString>;
|
|
8
|
-
},
|
|
9
|
-
type: string;
|
|
10
|
-
url?: string | undefined;
|
|
11
|
-
}, {
|
|
12
|
-
type: string;
|
|
13
|
-
url?: string | undefined;
|
|
14
|
-
}>]>>;
|
|
8
|
+
}, z.core.$strip>]>>;
|
|
15
9
|
licenses: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
16
10
|
type: z.ZodString;
|
|
17
11
|
url: z.ZodOptional<z.ZodString>;
|
|
18
|
-
},
|
|
19
|
-
type: string;
|
|
20
|
-
url?: string | undefined;
|
|
21
|
-
}, {
|
|
22
|
-
type: string;
|
|
23
|
-
url?: string | undefined;
|
|
24
|
-
}>, "many">>;
|
|
12
|
+
}, z.core.$strip>>>;
|
|
25
13
|
packageManager: z.ZodOptional<z.ZodString>;
|
|
26
|
-
},
|
|
27
|
-
name: string;
|
|
28
|
-
version: string;
|
|
29
|
-
license?: string | {
|
|
30
|
-
type: string;
|
|
31
|
-
url?: string | undefined;
|
|
32
|
-
} | undefined;
|
|
33
|
-
licenses?: {
|
|
34
|
-
type: string;
|
|
35
|
-
url?: string | undefined;
|
|
36
|
-
}[] | undefined;
|
|
37
|
-
packageManager?: string | undefined;
|
|
38
|
-
}, {
|
|
39
|
-
name: string;
|
|
40
|
-
version: string;
|
|
41
|
-
license?: string | {
|
|
42
|
-
type: string;
|
|
43
|
-
url?: string | undefined;
|
|
44
|
-
} | undefined;
|
|
45
|
-
licenses?: {
|
|
46
|
-
type: string;
|
|
47
|
-
url?: string | undefined;
|
|
48
|
-
}[] | undefined;
|
|
49
|
-
packageManager?: string | undefined;
|
|
50
|
-
}>;
|
|
14
|
+
}, z.core.$strip>;
|
|
51
15
|
type PackageJson = z.infer<typeof packageJsonValidator>;
|
|
52
16
|
export declare const readPackageJson: (pathToPackageJson: string) => Promise<PackageJson>;
|
|
53
17
|
export declare const getLicenseExpression: (packageJson: PackageJson) => string;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
function _export(target, all) {
|
|
3
3
|
for(var name in all)Object.defineProperty(target, name, {
|
|
4
4
|
enumerable: true,
|
|
5
|
-
get: all
|
|
5
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
6
6
|
});
|
|
7
7
|
}
|
|
8
8
|
_export(exports, {
|
|
9
|
-
getLicenseExpression
|
|
9
|
+
get getLicenseExpression () {
|
|
10
10
|
return getLicenseExpression;
|
|
11
11
|
},
|
|
12
|
-
readPackageJson
|
|
12
|
+
get readPackageJson () {
|
|
13
13
|
return readPackageJson;
|
|
14
14
|
}
|
|
15
15
|
});
|
|
@@ -67,7 +67,7 @@ const doesFileExist = async (path)=>{
|
|
|
67
67
|
try {
|
|
68
68
|
const stats = await (0, _promises.stat)(path);
|
|
69
69
|
return stats.isFile();
|
|
70
|
-
} catch (
|
|
70
|
+
} catch (unused) {
|
|
71
71
|
return false;
|
|
72
72
|
}
|
|
73
73
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/license-cop/src/lib/dependency/package-json.ts"],"sourcesContent":["import { Stats } from \"fs\";\nimport { readFile, stat } from \"fs/promises\";\nimport { z } from \"zod\";\nimport { json5Parse } from \"../config/parsers/json5\";\nimport logger from \"../logger\";\n\nconst licenseSectionValidator = z.object({\n type: z.string(),\n url: z.string().optional()\n});\n\nconst packageJsonValidator = z.object({\n name: z.string(),\n version: z.string(),\n license: z.union([z.string(), licenseSectionValidator]).optional(),\n licenses: licenseSectionValidator.array().optional(),\n packageManager: z.string().optional()\n});\n\ntype PackageJson = z.infer<typeof packageJsonValidator>;\n\nexport const readPackageJson = async (pathToPackageJson: string): Promise<PackageJson> => {\n const doesPackageJsonExist = await doesFileExist(pathToPackageJson);\n if (!doesPackageJsonExist) {\n logger.verbose(`Cannot find the package.json: '${pathToPackageJson}'`);\n throw new Error(`Cannot find the file: '${pathToPackageJson}'`);\n }\n\n const packageJsonAsString: string = await readFile(pathToPackageJson, { encoding: \"utf8\" });\n\n const parsedFile = json5Parse<unknown>(packageJsonAsString);\n\n const packageJson = packageJsonValidator.safeParse(parsedFile);\n\n if (!packageJson.success) {\n throw new Error(\n `Unable to parse package.json: ${pathToPackageJson}: ${packageJson.error.message}`\n );\n }\n\n return packageJson.data;\n};\n\nexport const getLicenseExpression = (packageJson: PackageJson): string => {\n if (packageJson.license && typeof packageJson.license === \"string\") {\n return packageJson.license;\n }\n\n if (packageJson.license && typeof packageJson.license === \"object\") {\n return packageJson.license.type;\n }\n\n if (packageJson.licenses) {\n const licenses = packageJson.licenses.map<string>(license => license.type);\n\n if (licenses.length === 1) {\n return licenses[0];\n }\n\n return `(${licenses.join(\" AND \")})`;\n }\n\n return \"UNLICENSED\";\n};\n\nconst doesFileExist = async (path: string): Promise<boolean> => {\n try {\n const stats: Stats = await stat(path);\n return stats.isFile();\n } catch {\n return false;\n }\n};\n"],"names":["getLicenseExpression","readPackageJson","licenseSectionValidator","z","object","type","string","url","optional","packageJsonValidator","name","version","license","union","licenses","array","packageManager","pathToPackageJson","doesPackageJsonExist","doesFileExist","logger","verbose","Error","packageJsonAsString","readFile","encoding","parsedFile","json5Parse","packageJson","safeParse","success","error","message","data","map","length","join","path","stats","stat","isFile"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/license-cop/src/lib/dependency/package-json.ts"],"sourcesContent":["import { Stats } from \"fs\";\nimport { readFile, stat } from \"fs/promises\";\nimport { z } from \"zod\";\nimport { json5Parse } from \"../config/parsers/json5\";\nimport logger from \"../logger\";\n\nconst licenseSectionValidator = z.object({\n type: z.string(),\n url: z.string().optional()\n});\n\nconst packageJsonValidator = z.object({\n name: z.string(),\n version: z.string(),\n license: z.union([z.string(), licenseSectionValidator]).optional(),\n licenses: licenseSectionValidator.array().optional(),\n packageManager: z.string().optional()\n});\n\ntype PackageJson = z.infer<typeof packageJsonValidator>;\n\nexport const readPackageJson = async (pathToPackageJson: string): Promise<PackageJson> => {\n const doesPackageJsonExist = await doesFileExist(pathToPackageJson);\n if (!doesPackageJsonExist) {\n logger.verbose(`Cannot find the package.json: '${pathToPackageJson}'`);\n throw new Error(`Cannot find the file: '${pathToPackageJson}'`);\n }\n\n const packageJsonAsString: string = await readFile(pathToPackageJson, { encoding: \"utf8\" });\n\n const parsedFile = json5Parse<unknown>(packageJsonAsString);\n\n const packageJson = packageJsonValidator.safeParse(parsedFile);\n\n if (!packageJson.success) {\n throw new Error(\n `Unable to parse package.json: ${pathToPackageJson}: ${packageJson.error.message}`\n );\n }\n\n return packageJson.data;\n};\n\nexport const getLicenseExpression = (packageJson: PackageJson): string => {\n if (packageJson.license && typeof packageJson.license === \"string\") {\n return packageJson.license;\n }\n\n if (packageJson.license && typeof packageJson.license === \"object\") {\n return packageJson.license.type;\n }\n\n if (packageJson.licenses) {\n const licenses = packageJson.licenses.map<string>(license => license.type);\n\n if (licenses.length === 1) {\n return licenses[0];\n }\n\n return `(${licenses.join(\" AND \")})`;\n }\n\n return \"UNLICENSED\";\n};\n\nconst doesFileExist = async (path: string): Promise<boolean> => {\n try {\n const stats: Stats = await stat(path);\n return stats.isFile();\n } catch {\n return false;\n }\n};\n"],"names":["getLicenseExpression","readPackageJson","licenseSectionValidator","z","object","type","string","url","optional","packageJsonValidator","name","version","license","union","licenses","array","packageManager","pathToPackageJson","doesPackageJsonExist","doesFileExist","logger","verbose","Error","packageJsonAsString","readFile","encoding","parsedFile","json5Parse","packageJson","safeParse","success","error","message","data","map","length","join","path","stats","stat","isFile"],"mappings":";;;;;;;;QA2CaA;eAAAA;;QAtBAC;eAAAA;;;0BApBkB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,OAAO,KAAK,UAAU;QAClE,OAAOgB,YAAYhB,OAAO,CAACP,IAAI;IACjC;IAEA,IAAIuB,YAAYd,QAAQ,EAAE;QACxB,MAAMA,WAAWc,YAAYd,QAAQ,CAACoB,GAAG,CAAStB,CAAAA,UAAWA,QAAQP,IAAI;QAEzE,IAAIS,SAASqB,MAAM,KAAK,GAAG;YACzB,OAAOrB,QAAQ,CAAC,EAAE;QACpB;QAEA,OAAO,CAAC,CAAC,EAAEA,SAASsB,IAAI,CAAC,SAAS,CAAC,CAAC;IACtC;IAEA,OAAO;AACT;AAEA,MAAMjB,gBAAgB,OAAOkB;IAC3B,IAAI;QACF,MAAMC,QAAe,MAAMC,IAAAA,cAAI,EAACF;QAChC,OAAOC,MAAME,MAAM;IACrB,EAAE,eAAM;QACN,OAAO;IACT;AACF"}
|
|
@@ -19,7 +19,7 @@ const pnpmDependencyScanning = async (options)=>{
|
|
|
19
19
|
const packagesWithAllowedLicenses = new Map();
|
|
20
20
|
const packagesWithNoLicenses = new Map();
|
|
21
21
|
const packagesWithForbiddenLicenses = new Map();
|
|
22
|
-
const dependencyHierarchies = await (0, _reviewingdependencieshierarchy.
|
|
22
|
+
const dependencyHierarchies = await (0, _reviewingdependencieshierarchy.buildDependenciesTree)([
|
|
23
23
|
workingDirectory
|
|
24
24
|
], {
|
|
25
25
|
depth: Infinity,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/license-cop/src/lib/dependency-scanning/pnpm.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/license-cop/src/lib/dependency-scanning/pnpm.ts"],"sourcesContent":["import { buildDependenciesTree, DependencyNode } from \"@pnpm/reviewing.dependencies-hierarchy\";\nimport { join } from \"node:path\";\nimport { getLicenseExpression, readPackageJson } from \"../dependency/package-json\";\nimport { isAllowedPackage } from \"../dependency/package-rules\";\nimport logger from \"../logger\";\nimport {\n AllowedPackage,\n CheckLicensesResult,\n ForbiddenLicenseResult,\n LicensedPackage,\n NoLicenseResult\n} from \"../result\";\nimport { calculateIssues } from \"../spdx/calculate-issues\";\nimport { parseLicenseExpression } from \"../spdx/parse-license-expression\";\nimport { joinStringArray } from \"../utils/join-string-array\";\nimport { DependencyScanningOptions } from \"./options\";\n\nexport const pnpmDependencyScanning = async (\n options: DependencyScanningOptions\n): Promise<CheckLicensesResult> => {\n const {\n workingDirectory,\n allowedLicenses,\n allowedPackages,\n includeDevDependencies,\n devDependenciesOnly\n } = options;\n\n const foundAllowedPackages = new Map<string, AllowedPackage>();\n const packagesWithAllowedLicenses = new Map<string, LicensedPackage>();\n const packagesWithNoLicenses = new Map<string, NoLicenseResult>();\n const packagesWithForbiddenLicenses = new Map<string, ForbiddenLicenseResult>();\n\n const dependencyHierarchies = await buildDependenciesTree([workingDirectory], {\n depth: Infinity,\n include: {\n dependencies: !devDependenciesOnly,\n devDependencies: includeDevDependencies,\n optionalDependencies: false\n },\n lockfileDir: workingDirectory,\n virtualStoreDirMaxLength: Infinity\n });\n\n // This function is very similar to the one in npm.ts\n // If you change this, you probably want to change that one too\n const parseNode = async (node: DependencyNode) => {\n logger.verbose(`Parsing node: ${node.name}`);\n\n const pkgId = `${node.alias}@${node.version}`;\n const packageJsonPath = join(node.path, \"package.json\");\n const packageJson = await readPackageJson(packageJsonPath);\n\n if (isAllowedPackage(packageJson.name, packageJson.version, allowedPackages)) {\n logger.verbose(`Package ${packageJson.name} is an allowed package`);\n foundAllowedPackages.set(pkgId, {\n name: packageJson.name,\n version: packageJson.version\n });\n\n await parseNodes(node.dependencies);\n return;\n }\n\n const rawLicenseExpression = getLicenseExpression(packageJson);\n const licenseExpression = parseLicenseExpression(rawLicenseExpression);\n\n if (licenseExpression.type === \"unlicensed\") {\n logger.verbose(`Package ${packageJson.name} is unlicensed`);\n packagesWithNoLicenses.set(pkgId, {\n name: packageJson.name,\n version: packageJson.version\n });\n\n await parseNodes(node.dependencies);\n return;\n }\n\n const licenseIssues = calculateIssues(licenseExpression, allowedLicenses);\n const joinedIssues = joinStringArray(licenseIssues);\n\n if (licenseIssues.length > 0) {\n logger.verbose(`Package ${packageJson.name} has the forbidden license: ${joinedIssues}`);\n packagesWithForbiddenLicenses.set(pkgId, {\n name: packageJson.name,\n version: packageJson.version,\n licenseIdentifiers: joinedIssues,\n spdxExpression: rawLicenseExpression\n });\n } else {\n logger.verbose(\n `Package ${packageJson.name} has the allowed license: ${rawLicenseExpression}`\n );\n packagesWithAllowedLicenses.set(pkgId, {\n name: packageJson.name,\n version: packageJson.version,\n spdxExpression: rawLicenseExpression,\n licenses: licenseExpression\n });\n }\n\n await parseNodes(node.dependencies);\n };\n\n const parseNodes = async (nodes: DependencyNode[] | undefined) => {\n if (!nodes) {\n return;\n }\n\n for (const node of nodes) {\n await parseNode(node);\n }\n };\n\n for (const hierarchies of Object.values(dependencyHierarchies)) {\n await parseNodes(hierarchies.dependencies);\n await parseNodes(hierarchies.devDependencies);\n await parseNodes(hierarchies.optionalDependencies);\n }\n\n return {\n allowedPackages: new Set(foundAllowedPackages.values()),\n allowedLicenses: new Set(packagesWithAllowedLicenses.values()),\n noLicenses: new Set(packagesWithNoLicenses.values()),\n forbiddenLicenses: new Set(packagesWithForbiddenLicenses.values())\n };\n};\n"],"names":["pnpmDependencyScanning","options","workingDirectory","allowedLicenses","allowedPackages","includeDevDependencies","devDependenciesOnly","foundAllowedPackages","Map","packagesWithAllowedLicenses","packagesWithNoLicenses","packagesWithForbiddenLicenses","dependencyHierarchies","buildDependenciesTree","depth","Infinity","include","dependencies","devDependencies","optionalDependencies","lockfileDir","virtualStoreDirMaxLength","parseNode","node","logger","verbose","name","pkgId","alias","version","packageJsonPath","join","path","packageJson","readPackageJson","isAllowedPackage","set","parseNodes","rawLicenseExpression","getLicenseExpression","licenseExpression","parseLicenseExpression","type","licenseIssues","calculateIssues","joinedIssues","joinStringArray","length","licenseIdentifiers","spdxExpression","licenses","nodes","hierarchies","Object","values","Set","noLicenses","forbiddenLicenses"],"mappings":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AWe,YAAYjC,oBAAoB;IACnD;IAEA,OAAO;QACLf,iBAAiB,IAAImD,IAAIhD,qBAAqB+C,MAAM;QACpDnD,iBAAiB,IAAIoD,IAAI9C,4BAA4B6C,MAAM;QAC3DE,YAAY,IAAID,IAAI7C,uBAAuB4C,MAAM;QACjDG,mBAAmB,IAAIF,IAAI5C,8BAA8B2C,MAAM;IACjE;AACF"}
|
package/src/lib/license-cop.js
CHANGED
|
@@ -24,10 +24,9 @@ function _extends() {
|
|
|
24
24
|
return _extends.apply(this, arguments);
|
|
25
25
|
}
|
|
26
26
|
const checkLicenses = async (options)=>{
|
|
27
|
+
var _options_includeDevDependencies, _options_devDependenciesOnly;
|
|
27
28
|
const fullProjectPath = resolvePath(options.workingDirectory);
|
|
28
|
-
var _options_includeDevDependencies;
|
|
29
29
|
const includeDevDependencies = (_options_includeDevDependencies = options.includeDevDependencies) != null ? _options_includeDevDependencies : false;
|
|
30
|
-
var _options_devDependenciesOnly;
|
|
31
30
|
const devDependenciesOnly = (_options_devDependenciesOnly = options.devDependenciesOnly) != null ? _options_devDependenciesOnly : false;
|
|
32
31
|
const dependencyScanningOptions = _extends({}, options, {
|
|
33
32
|
workingDirectory: fullProjectPath,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/license-cop/src/lib/license-cop.ts"],"sourcesContent":["import { isAbsolute, join } from \"path\";\nimport { npmDependencyScanning } from \"./dependency-scanning/npm\";\nimport { DependencyScanningOptions } from \"./dependency-scanning/options\";\nimport { pnpmDependencyScanning } from \"./dependency-scanning/pnpm\";\nimport { getPackageManager } from \"./dependency/get-package-manager\";\nimport { CheckLicensesResult } from \"./result\";\n\nexport type LicenseCopOptions = {\n allowedLicenses: string[];\n allowedPackages: string[];\n workingDirectory?: string;\n includeDevDependencies?: boolean;\n devDependenciesOnly?: boolean;\n};\n\nexport const checkLicenses = async (options: LicenseCopOptions): Promise<CheckLicensesResult> => {\n const fullProjectPath = resolvePath(options.workingDirectory);\n const includeDevDependencies = options.includeDevDependencies ?? false;\n const devDependenciesOnly = options.devDependenciesOnly ?? false;\n\n const dependencyScanningOptions: DependencyScanningOptions = {\n ...options,\n workingDirectory: fullProjectPath,\n includeDevDependencies,\n devDependenciesOnly\n };\n\n const packageManager = await getPackageManager(fullProjectPath);\n\n switch (packageManager) {\n case \"pnpm\":\n return pnpmDependencyScanning(dependencyScanningOptions);\n default:\n return npmDependencyScanning(dependencyScanningOptions);\n }\n};\n\nconst resolvePath = (path?: string): string => {\n if (!path) {\n return process.cwd();\n }\n\n return isAbsolute(path) ? path : join(process.cwd(), path);\n};\n"],"names":["checkLicenses","options","fullProjectPath","resolvePath","workingDirectory","includeDevDependencies","devDependenciesOnly","dependencyScanningOptions","packageManager","getPackageManager","pnpmDependencyScanning","npmDependencyScanning","path","process","cwd","isAbsolute","join"],"mappings":";+BAeaA;;;eAAAA;;;sBAfoB;qBACK;sBAEC;mCACL;;;;;;;;;;;;;;;AAW3B,MAAMA,gBAAgB,OAAOC;
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/license-cop/src/lib/license-cop.ts"],"sourcesContent":["import { isAbsolute, join } from \"path\";\nimport { npmDependencyScanning } from \"./dependency-scanning/npm\";\nimport { DependencyScanningOptions } from \"./dependency-scanning/options\";\nimport { pnpmDependencyScanning } from \"./dependency-scanning/pnpm\";\nimport { getPackageManager } from \"./dependency/get-package-manager\";\nimport { CheckLicensesResult } from \"./result\";\n\nexport type LicenseCopOptions = {\n allowedLicenses: string[];\n allowedPackages: string[];\n workingDirectory?: string;\n includeDevDependencies?: boolean;\n devDependenciesOnly?: boolean;\n};\n\nexport const checkLicenses = async (options: LicenseCopOptions): Promise<CheckLicensesResult> => {\n const fullProjectPath = resolvePath(options.workingDirectory);\n const includeDevDependencies = options.includeDevDependencies ?? false;\n const devDependenciesOnly = options.devDependenciesOnly ?? false;\n\n const dependencyScanningOptions: DependencyScanningOptions = {\n ...options,\n workingDirectory: fullProjectPath,\n includeDevDependencies,\n devDependenciesOnly\n };\n\n const packageManager = await getPackageManager(fullProjectPath);\n\n switch (packageManager) {\n case \"pnpm\":\n return pnpmDependencyScanning(dependencyScanningOptions);\n default:\n return npmDependencyScanning(dependencyScanningOptions);\n }\n};\n\nconst resolvePath = (path?: string): string => {\n if (!path) {\n return process.cwd();\n }\n\n return isAbsolute(path) ? path : join(process.cwd(), path);\n};\n"],"names":["checkLicenses","options","fullProjectPath","resolvePath","workingDirectory","includeDevDependencies","devDependenciesOnly","dependencyScanningOptions","packageManager","getPackageManager","pnpmDependencyScanning","npmDependencyScanning","path","process","cwd","isAbsolute","join"],"mappings":";+BAeaA;;;eAAAA;;;sBAfoB;qBACK;sBAEC;mCACL;;;;;;;;;;;;;;;AAW3B,MAAMA,gBAAgB,OAAOC;QAEHA,iCACHA;IAF5B,MAAMC,kBAAkBC,YAAYF,QAAQG,gBAAgB;IAC5D,MAAMC,0BAAyBJ,kCAAAA,QAAQI,sBAAsB,YAA9BJ,kCAAkC;IACjE,MAAMK,uBAAsBL,+BAAAA,QAAQK,mBAAmB,YAA3BL,+BAA+B;IAE3D,MAAMM,4BAAuD,aACxDN;QACHG,kBAAkBF;QAClBG;QACAC;;IAGF,MAAME,iBAAiB,MAAMC,IAAAA,oCAAiB,EAACP;IAE/C,OAAQM;QACN,KAAK;YACH,OAAOE,IAAAA,4BAAsB,EAACH;QAChC;YACE,OAAOI,IAAAA,0BAAqB,EAACJ;IACjC;AACF;AAEA,MAAMJ,cAAc,CAACS;IACnB,IAAI,CAACA,MAAM;QACT,OAAOC,QAAQC,GAAG;IACpB;IAEA,OAAOC,IAAAA,gBAAU,EAACH,QAAQA,OAAOI,IAAAA,UAAI,EAACH,QAAQC,GAAG,IAAIF;AACvD"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
// Operators
|
|
2
1
|
"use strict";
|
|
3
2
|
function _export(target, all) {
|
|
4
3
|
for(var name in all)Object.defineProperty(target, name, {
|
|
5
4
|
enumerable: true,
|
|
6
|
-
get: all
|
|
5
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
7
6
|
});
|
|
8
7
|
}
|
|
9
8
|
_export(exports, {
|
|
10
|
-
isOperator
|
|
9
|
+
get isOperator () {
|
|
11
10
|
return isOperator;
|
|
12
11
|
},
|
|
13
|
-
isParenthesis
|
|
12
|
+
get isParenthesis () {
|
|
14
13
|
return isParenthesis;
|
|
15
14
|
}
|
|
16
15
|
});
|
|
16
|
+
// Operators
|
|
17
17
|
const operators = [
|
|
18
18
|
"AND",
|
|
19
19
|
"OR"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/license-cop/src/lib/spdx/types/token.ts"],"sourcesContent":["// Operators\n\nconst operators = [\"AND\", \"OR\"] as const;\nexport const isOperator = (value: string): value is Operator =>\n operators.includes(value as Operator);\n\nexport type Operator = (typeof operators)[number];\nexport type OperatorToken = {\n type: \"operator\";\n value: Operator;\n};\n\n// With\n\nexport type WithToken = {\n type: \"with\";\n};\n\n// Identifiers\n\nexport type IdentifierToken = {\n type: \"identifier\";\n value: string;\n};\n\n// Parenthesis\n\nconst parenthesis = [\"(\", \")\"] as const;\nexport const isParenthesis = (value: string): value is Parenthesis =>\n parenthesis.includes(value as Parenthesis);\n\nexport type Parenthesis = (typeof parenthesis)[number];\nexport type ParenthesisToken = {\n type: \"parenthesis\";\n value: Parenthesis;\n};\n\nexport type Token = OperatorToken | WithToken | IdentifierToken | ParenthesisToken;\n"],"names":["isOperator","isParenthesis","operators","value","includes","parenthesis"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/license-cop/src/lib/spdx/types/token.ts"],"sourcesContent":["// Operators\n\nconst operators = [\"AND\", \"OR\"] as const;\nexport const isOperator = (value: string): value is Operator =>\n operators.includes(value as Operator);\n\nexport type Operator = (typeof operators)[number];\nexport type OperatorToken = {\n type: \"operator\";\n value: Operator;\n};\n\n// With\n\nexport type WithToken = {\n type: \"with\";\n};\n\n// Identifiers\n\nexport type IdentifierToken = {\n type: \"identifier\";\n value: string;\n};\n\n// Parenthesis\n\nconst parenthesis = [\"(\", \")\"] as const;\nexport const isParenthesis = (value: string): value is Parenthesis =>\n parenthesis.includes(value as Parenthesis);\n\nexport type Parenthesis = (typeof parenthesis)[number];\nexport type ParenthesisToken = {\n type: \"parenthesis\";\n value: Parenthesis;\n};\n\nexport type Token = OperatorToken | WithToken | IdentifierToken | ParenthesisToken;\n"],"names":["isOperator","isParenthesis","operators","value","includes","parenthesis"],"mappings":";;;;;;;;QAGaA;eAAAA;;QAyBAC;eAAAA;;;AA5Bb,YAAY;AAEZ,MAAMC,YAAY;IAAC;IAAO;CAAK;AACxB,MAAMF,aAAa,CAACG,QACzBD,UAAUE,QAAQ,CAACD;AAqBrB,cAAc;AAEd,MAAME,cAAc;IAAC;IAAK;CAAI;AACvB,MAAMJ,gBAAgB,CAACE,QAC5BE,YAAYD,QAAQ,CAACD"}
|