@visulima/package 1.0.0 → 1.2.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/CHANGELOG.md +24 -0
- package/dist/{chunk-MYRZ7SEG.js → chunk-7WLQPGXB.js} +2 -2
- package/dist/{chunk-KWZ4YGPC.js → chunk-IWQKH4TN.js} +3 -3
- package/dist/chunk-IWQKH4TN.js.map +1 -0
- package/dist/chunk-QQJUJRI7.js +10 -0
- package/dist/chunk-QQJUJRI7.js.map +1 -0
- package/dist/{chunk-HSXXY5E3.js → chunk-T4PCL5Z7.js} +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/monorepo.js +2 -2
- package/dist/package-manager.d.ts +5 -1
- package/dist/package-manager.js +1 -1
- package/dist/package.js +2 -2
- package/dist/tsconfig.d.ts +1 -1
- package/dist/tsconfig.js +1 -1
- package/package.json +11 -5
- package/dist/chunk-HN5TULBQ.js +0 -10
- package/dist/chunk-HN5TULBQ.js.map +0 -1
- package/dist/chunk-KWZ4YGPC.js.map +0 -1
- /package/dist/{chunk-MYRZ7SEG.js.map → chunk-7WLQPGXB.js.map} +0 -0
- /package/dist/{chunk-HSXXY5E3.js.map → chunk-T4PCL5Z7.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
## @visulima/package [1.2.0](https://github.com/visulima/visulima/compare/@visulima/package@1.1.0...@visulima/package@1.2.0) (2023-10-24)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* extended findTSConfig with jsconfig.json search ([13902fd](https://github.com/visulima/visulima/commit/13902fdc8d3e08719ad52dd89fcc183d9bd9d042))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* updated deps ([4eedb60](https://github.com/visulima/visulima/commit/4eedb604c4f78cf331195e2c053dc72e1c6cf9ad))
|
|
12
|
+
|
|
13
|
+
## @visulima/package [1.1.0](https://github.com/visulima/visulima/compare/@visulima/package@1.0.0...@visulima/package@1.1.0) (2023-10-17)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* added new function that identify the initiating package-manager ([0c89c6a](https://github.com/visulima/visulima/commit/0c89c6ae32641f13ad8ac818f69ebc18d6d17f0e))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* removed bun from the dev deps of the package lib ([95c790f](https://github.com/visulima/visulima/commit/95c790f15bc66d6ff0d4b559f4890bb896ff018e))
|
|
24
|
+
|
|
1
25
|
## @visulima/package 1.0.0 (2023-10-15)
|
|
2
26
|
|
|
3
27
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a } from './chunk-
|
|
1
|
+
import { a } from './chunk-IWQKH4TN.js';
|
|
2
2
|
import { dirname } from 'path';
|
|
3
3
|
import { findUp } from 'find-up';
|
|
4
4
|
|
|
@@ -6,4 +6,4 @@ var c=async o=>{try{let a$1=await a(o);return dirname(a$1)}catch{}let t=await fi
|
|
|
6
6
|
|
|
7
7
|
export { c as a };
|
|
8
8
|
//# sourceMappingURL=out.js.map
|
|
9
|
-
//# sourceMappingURL=chunk-
|
|
9
|
+
//# sourceMappingURL=chunk-7WLQPGXB.js.map
|
|
@@ -4,8 +4,8 @@ import { join, dirname } from 'path';
|
|
|
4
4
|
import { findUp } from 'find-up';
|
|
5
5
|
import { parsePackage, readPackage } from 'read-pkg';
|
|
6
6
|
|
|
7
|
-
var g=["yarn.lock","package-lock.json","pnpm-lock.yaml","npm-shrinkwrap.json","bun.lockb"],
|
|
7
|
+
var g=["yarn.lock","package-lock.json","pnpm-lock.yaml","npm-shrinkwrap.json","bun.lockb"],x=async n=>{let a=await findUp(g,{allowSymlinks:!1,type:"file",...n&&{cwd:n}});if(!a)throw new Error("Could not find lock file");return a},b=async n=>{let a=await findUp(e=>{let o;if(g.forEach(i=>{!o&&existsSync(join(e,i))&&(o=join(e,i));}),o)return o;let r=join(e,"package.json");if(existsSync(r)&&parsePackage(readFileSync(r,"utf8")).packageManager!==void 0)return r},{...n&&{cwd:n},allowSymlinks:!1});if(!a)throw new Error("Could not find lock file");if(a.endsWith("package.json")){let e=await readPackage({cwd:dirname(a),normalize:!0});if(e.packageManager){let r=["npm","yarn","pnpm","bun"].find(i=>e.packageManager.startsWith(i));if(r)return {packageManager:r,path:dirname(a)}}}if(a.endsWith("yarn.lock"))return {packageManager:"yarn",path:dirname(a)};if(a.endsWith("package-lock.json")||a.endsWith("npm-shrinkwrap.json"))return {packageManager:"npm",path:dirname(a)};if(a.endsWith("pnpm-lock.yaml"))return {packageManager:"pnpm",path:dirname(a)};if(a.endsWith("bun.lockb"))return {packageManager:"bun",path:dirname(a)};throw new Error("Could not find lock file")},j=n=>execSync(`${n} --version`).toString("utf8").trim(),S=async()=>{if(!process.env.npm_config_user_agent)return;let n=process.env.npm_config_user_agent.split(" ")[0],a=n.lastIndexOf("/"),e=n.slice(0,Math.max(0,a));return {name:e==="npminstall"?"cnpm":e,version:n.slice(Math.max(0,a+1))}};
|
|
8
8
|
|
|
9
|
-
export {
|
|
9
|
+
export { x as a, b, j as c, S as d };
|
|
10
10
|
//# sourceMappingURL=out.js.map
|
|
11
|
-
//# sourceMappingURL=chunk-
|
|
11
|
+
//# sourceMappingURL=chunk-IWQKH4TN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/package-manager.ts"],"names":["execSync","existsSync","readFileSync","dirname","join","findUp","parsePackage","readPackage","lockFileNames","findLockFile","cwd","filePath","findPackageManager","foundFile","directory","lockFile","lockFileName","packageJsonFilePath","packageJson","foundPackageManager","prefix","getPackageManagerVersion","name","identifyInitiatingPackageManager","pmSpec","separatorPos"],"mappings":"AAAA,OAAS,YAAAA,MAAgB,gBACzB,OAAS,cAAAC,EAAY,gBAAAC,MAAoB,KACzC,OA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S,WAAW,EAC9B,MAAO,CACH,eAAgB,OAChB,KAAMV,EAAQU,CAAS,CAC3B,EAGJ,GAAIA,EAAU,SAAS,mBAAmB,GAAKA,EAAU,SAAS,qBAAqB,EACnF,MAAO,CACH,eAAgB,MAChB,KAAMV,EAAQU,CAAS,CAC3B,EAGJ,GAAIA,EAAU,SAAS,gBAAgB,EACnC,MAAO,CACH,eAAgB,OAChB,KAAMV,EAAQU,CAAS,CAC3B,EAGJ,GAAIA,EAAU,SAAS,WAAW,EAC9B,MAAO,CACH,eAAgB,MAChB,KAAMV,EAAQU,CAAS,CAC3B,EAGJ,MAAM,IAAI,MAAM,0BAA0B,CAC9C,EAQaQ,EAA4BC,GAAyBtB,EAAS,GAAGsB,CAAI,YAAY,EAAE,SAAS,MAAM,EAAE,KAAK,EAWzGC,EAAmC,SAM3C,CACD,GAAI,CAAC,QAAQ,IAAI,sBACb,OAGJ,IAAMC,EAAS,QAAQ,IAAI,sBAAyB,MAAM,GAAG,EAAE,CAAC,EAC1DC,EAAeD,EAAO,YAAY,GAAG,EACrCF,EAAOE,EAAO,MAAM,EAAG,KAAK,IAAI,EAAGC,CAAY,CAAC,EAEtD,MAAO,CACH,KAAMH,IAAS,aAAe,OAAUA,EACxC,QAASE,EAAO,MAAM,KAAK,IAAI,EAAGC,EAAe,CAAC,CAAC,CACvD,CACJ","sourcesContent":["import { execSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\nimport type { Options } from \"find-up\";\nimport { findUp } from \"find-up\";\nimport { parsePackage, readPackage } from \"read-pkg\";\n\nconst lockFileNames = [\"yarn.lock\", \"package-lock.json\", \"pnpm-lock.yaml\", \"npm-shrinkwrap.json\", \"bun.lockb\"] as const;\n\n/**\n * An asynchronous function that finds a lock file in the specified directory or any of its parent directories.\n *\n * @param cwd - Optional. The directory path to start the search from. The type of `cwd` is part of an `Options` type,\n * specifically `Options[\"cwd\"]`. Defaults to the current working directory.\n * @returns A `Promise` that resolves with the path of the found lock file.\n * The type of the returned promise is `Promise<string>`.\n * @throws An `Error` if no lock file is found.\n */\nexport const findLockFile = async (cwd?: Options[\"cwd\"]): Promise<string> => {\n const filePath = await findUp(lockFileNames, {\n allowSymlinks: false,\n type: \"file\",\n ...(cwd && { cwd }),\n });\n\n if (!filePath) {\n throw new Error(\"Could not find lock file\");\n }\n\n return filePath;\n};\n\nexport type PackageManager = \"bun\" | \"npm\" | \"pnpm\" | \"yarn\";\n\nexport type PackageManagerResult = {\n packageManager: PackageManager;\n path: string;\n};\n\n/**\n * An asynchronous function that finds the package manager used in a project based on the presence of lock files\n * or package.json configuration. If found, it returns the package manager and the path to the lock file or package.json.\n * Throws an error if no lock file or package.json is found.\n *\n * @param cwd - Optional. The current working directory to start the search from. The type of `cwd` is part of an `Options`\n * type, specifically `Options[\"cwd\"]`.\n * @returns A `Promise` that resolves to an object containing the package manager and path.\n * The return type of the function is `Promise<PackageManagerResult>`.\n * @throws An `Error` if no lock file or package.json is found.\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport const findPackageManager = async (cwd?: Options[\"cwd\"]): Promise<PackageManagerResult> => {\n const foundFile = await findUp(\n (directory) => {\n let lockFile: string | undefined;\n\n lockFileNames.forEach((lockFileName) => {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!lockFile && existsSync(join(directory, lockFileName))) {\n lockFile = join(directory, lockFileName);\n }\n });\n\n if (lockFile) {\n return lockFile;\n }\n\n const packageJsonFilePath = join(directory, \"package.json\");\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(packageJsonFilePath)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const packageJson = parsePackage(readFileSync(packageJsonFilePath, \"utf8\"));\n\n if (packageJson.packageManager !== undefined) {\n return packageJsonFilePath;\n }\n }\n\n return undefined;\n },\n {\n ...(cwd && { cwd }),\n allowSymlinks: false,\n },\n );\n\n if (!foundFile) {\n throw new Error(\"Could not find lock file\");\n }\n\n if (foundFile.endsWith(\"package.json\")) {\n const packageJson = await readPackage({ cwd: dirname(foundFile), normalize: true });\n\n if (packageJson.packageManager) {\n const packageManagerNames = [\"npm\", \"yarn\", \"pnpm\", \"bun\"] as const;\n const foundPackageManager = packageManagerNames.find((prefix) => (packageJson.packageManager as string).startsWith(prefix));\n\n if (foundPackageManager) {\n return {\n packageManager: foundPackageManager,\n path: dirname(foundFile),\n };\n }\n }\n }\n\n if (foundFile.endsWith(\"yarn.lock\")) {\n return {\n packageManager: \"yarn\",\n path: dirname(foundFile),\n };\n }\n\n if (foundFile.endsWith(\"package-lock.json\") || foundFile.endsWith(\"npm-shrinkwrap.json\")) {\n return {\n packageManager: \"npm\",\n path: dirname(foundFile),\n };\n }\n\n if (foundFile.endsWith(\"pnpm-lock.yaml\")) {\n return {\n packageManager: \"pnpm\",\n path: dirname(foundFile),\n };\n }\n\n if (foundFile.endsWith(\"bun.lockb\")) {\n return {\n packageManager: \"bun\",\n path: dirname(foundFile),\n };\n }\n\n throw new Error(\"Could not find lock file\");\n};\n\n/**\n * Function that retrieves the version of the specified package manager.\n *\n * @param name - The name of the package manager. The type of `name` is `string`.\n * @returns The version of the package manager. The return type of the function is `string`.\n */\nexport const getPackageManagerVersion = (name: string): string => execSync(`${name} --version`).toString(\"utf8\").trim();\n\n/**\n * An asynchronous function that detects what package manager executes the process.\n *\n * Supports npm, pnpm, Yarn, cnpm, and bun. And also any other package manager that sets the npm_config_user_agent env variable.\n *\n * @returns A `Promise` that resolves to an object containing the name and version of the package manager,\n * or undefined if the package manager information cannot be determined. The return type of the function\n * is `Promise<{ name: PackageManager | \"cnpm\"; version: string } | undefined>`.\n */\nexport const identifyInitiatingPackageManager = async (): Promise<\n | {\n name: PackageManager | \"cnpm\";\n version: string;\n }\n | undefined\n> => {\n if (!process.env[\"npm_config_user_agent\"]) {\n return undefined;\n }\n\n const pmSpec = process.env[\"npm_config_user_agent\"].split(\" \")[0] as string;\n const separatorPos = pmSpec.lastIndexOf(\"/\");\n const name = pmSpec.slice(0, Math.max(0, separatorPos));\n\n return {\n name: name === \"npminstall\" ? \"cnpm\" : (name as PackageManager),\n version: pmSpec.slice(Math.max(0, separatorPos + 1)),\n };\n};\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { a, b } from './chunk-C7FQQQI6.js';
|
|
2
|
+
import { mkdir } from 'fs/promises';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { getTsconfig } from 'get-tsconfig';
|
|
5
|
+
|
|
6
|
+
var w=async t=>{let i=t===void 0?void 0:a(t),o=await getTsconfig(i,"tsconfig.json");if(o===null&&(o=await getTsconfig(i,"jsconfig.json")),o===null)throw new Error("Could not find a tsconfig.json or jsconfig.json file.");return o},C=async(t,i={})=>{let o=a(i.cwd??process.cwd()),e=join(o,"tsconfig.json");await mkdir(o,{recursive:!0}),await b(e,t,i);};
|
|
7
|
+
|
|
8
|
+
export { w as a, C as b };
|
|
9
|
+
//# sourceMappingURL=out.js.map
|
|
10
|
+
//# sourceMappingURL=chunk-QQJUJRI7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tsconfig.ts"],"names":["mkdir","join","getTsconfig","findTSConfig","cwd","searchPath","to_path_default","config","writeTSConfig","tsConfig","options","directory","path","writeJsonFile"],"mappings":"+CAAA,OAAS,SAAAA,MAAa,cACtB,OAAS,QAAAC,MAAY,OAGrB,OAAS,eAAAC,MAAmB,eAgBrB,IAAMC,EAAe,MAAOC,GAAgD,CAC/E,IAAMC,EAAaD,IAAQ,OAAY,OAAYE,EAAOF,CAAG,EAIzDG,EAAS,MAAML,EAAYG,EAAY,eAAe,EAO1D,GALIE,IAAW,OAEXA,EAAS,MAAML,EAAYG,EAAY,eAAe,GAGtDE,IAAW,KACX,MAAM,IAAI,MAAM,uDAAuD,EAG3E,OAAOA,CACX,EAWaC,EAAgB,MAAOC,EAAwBC,EAAiD,CAAC,IAAqB,CAC/H,IAAMC,EAAYL,EAAOI,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAC/CE,EAAOX,EAAKU,EAAW,eAAe,EAG5C,MAAMX,EAAMW,EAAW,CAAE,UAAW,EAAK,CAAC,EAE1C,MAAME,EAAcD,EAAMH,EAAUC,CAAO,CAC/C","sourcesContent":["import { mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport type { TsConfigJson, TsConfigResult } from \"get-tsconfig\";\nimport { getTsconfig } from \"get-tsconfig\";\n\nimport toPath from \"./utils/to-path\";\nimport type { WriteOptions } from \"./utils/write-json\";\nimport { writeJsonFile } from \"./utils/write-json\";\n\n/**\n * An asynchronous function that retrieves the TSConfig by searching for the \"tsconfig.json\" first,\n * second attempt is to look for the \"jsconfig.json\" file from a given current working directory.\n *\n * @param cwd - Optional. The current working directory from which to search for the \"tsconfig.json\" file.\n * The type of `cwd` is `string`.\n * @returns A `Promise` that resolves to the TSConfig result object.\n * The return type of the function is `Promise<TsConfigResult>`.\n * @throws An `Error` when the \"tsconfig.json\" file is not found.\n */\nexport const findTSConfig = async (cwd?: URL | string): Promise<TsConfigResult> => {\n const searchPath = cwd === undefined ? undefined : toPath(cwd);\n\n // wrong typing in get-tsconfig\n // eslint-disable-next-line @typescript-eslint/await-thenable\n let config = await getTsconfig(searchPath, \"tsconfig.json\");\n\n if (config === null) {\n // eslint-disable-next-line @typescript-eslint/await-thenable\n config = await getTsconfig(searchPath, \"jsconfig.json\");\n }\n\n if (config === null) {\n throw new Error(\"Could not find a tsconfig.json or jsconfig.json file.\");\n }\n\n return config;\n};\n\n/**\n * An asynchronous function that writes the provided TypeScript configuration object to a tsconfig.json file.\n *\n * @param tsConfig - The TypeScript configuration object to write. The type of `tsConfig` is `TsConfigJson`.\n * @param options - Optional. The write options and the current working directory. The type of `options` is an\n * intersection type of `WriteOptions` and a Record type with an optional `cwd` key of type `string`.\n * @returns A `Promise` that resolves when the tsconfig.json file has been written.\n * The return type of function is `Promise<void>`.\n */\nexport const writeTSConfig = async (tsConfig: TsConfigJson, options: WriteOptions & { cwd?: URL | string } = {}): Promise<void> => {\n const directory = toPath(options.cwd ?? process.cwd());\n const path = join(directory, \"tsconfig.json\");\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await mkdir(directory, { recursive: true });\n\n await writeJsonFile(path, tsConfig, options);\n};\n\nexport type { TsConfigJson, TsConfigJsonResolved, TsConfigResult } from \"get-tsconfig\";\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b } from './chunk-
|
|
1
|
+
import { b } from './chunk-IWQKH4TN.js';
|
|
2
2
|
import { readFileSync, existsSync } from 'fs';
|
|
3
3
|
import { dirname, join } from 'path';
|
|
4
4
|
import { findUp } from 'find-up';
|
|
@@ -8,4 +8,4 @@ var j=async e=>{let r=await findUp(["lerna.json","turbo.json"],{allowSymlinks:!1
|
|
|
8
8
|
|
|
9
9
|
export { j as a };
|
|
10
10
|
//# sourceMappingURL=out.js.map
|
|
11
|
-
//# sourceMappingURL=chunk-
|
|
11
|
+
//# sourceMappingURL=chunk-T4PCL5Z7.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { RootMonorepo, Strategy, findMonorepoRoot } from './monorepo.js';
|
|
2
2
|
export { findPackageRoot } from './package.js';
|
|
3
3
|
export { NormalizedReadResult, findPackageJson, writePackageJson } from './package-json.js';
|
|
4
|
-
export { PackageManager, PackageManagerResult, findLockFile, findPackageManager, getPackageManagerVersion } from './package-manager.js';
|
|
4
|
+
export { PackageManager, PackageManagerResult, findLockFile, findPackageManager, getPackageManagerVersion, identifyInitiatingPackageManager } from './package-manager.js';
|
|
5
5
|
export { findTSConfig, writeTSConfig } from './tsconfig.js';
|
|
6
6
|
export { NormalizedPackageJson, parsePackage as parsePackageJson } from 'read-pkg';
|
|
7
|
-
export { TsConfigJson, TsConfigJsonResolved } from 'get-tsconfig';
|
|
7
|
+
export { TsConfigJson, TsConfigJsonResolved, TsConfigResult } from 'get-tsconfig';
|
|
8
8
|
import 'find-up';
|
|
9
9
|
import './write-json-7d6e6751.js';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { a as findMonorepoRoot } from './chunk-
|
|
2
|
-
export { a as findPackageRoot } from './chunk-
|
|
1
|
+
export { a as findMonorepoRoot } from './chunk-T4PCL5Z7.js';
|
|
2
|
+
export { a as findPackageRoot } from './chunk-7WLQPGXB.js';
|
|
3
3
|
export { a as findPackageJson, c as parsePackageJson, b as writePackageJson } from './chunk-7TF75EA4.js';
|
|
4
|
-
export { a as findLockFile, b as findPackageManager, c as getPackageManagerVersion } from './chunk-
|
|
5
|
-
export { a as findTSConfig, b as writeTSConfig } from './chunk-
|
|
4
|
+
export { a as findLockFile, b as findPackageManager, c as getPackageManagerVersion, d as identifyInitiatingPackageManager } from './chunk-IWQKH4TN.js';
|
|
5
|
+
export { a as findTSConfig, b as writeTSConfig } from './chunk-QQJUJRI7.js';
|
|
6
6
|
import './chunk-C7FQQQI6.js';
|
|
7
7
|
//# sourceMappingURL=out.js.map
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/dist/monorepo.js
CHANGED
|
@@ -8,5 +8,9 @@ type PackageManagerResult = {
|
|
|
8
8
|
};
|
|
9
9
|
declare const findPackageManager: (cwd?: Options["cwd"]) => Promise<PackageManagerResult>;
|
|
10
10
|
declare const getPackageManagerVersion: (name: string) => string;
|
|
11
|
+
declare const identifyInitiatingPackageManager: () => Promise<{
|
|
12
|
+
name: PackageManager | "cnpm";
|
|
13
|
+
version: string;
|
|
14
|
+
} | undefined>;
|
|
11
15
|
|
|
12
|
-
export { PackageManager, PackageManagerResult, findLockFile, findPackageManager, getPackageManagerVersion };
|
|
16
|
+
export { PackageManager, PackageManagerResult, findLockFile, findPackageManager, getPackageManagerVersion, identifyInitiatingPackageManager };
|
package/dist/package-manager.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { a as findLockFile, b as findPackageManager, c as getPackageManagerVersion } from './chunk-
|
|
1
|
+
export { a as findLockFile, b as findPackageManager, c as getPackageManagerVersion, d as identifyInitiatingPackageManager } from './chunk-IWQKH4TN.js';
|
|
2
2
|
//# sourceMappingURL=out.js.map
|
|
3
3
|
//# sourceMappingURL=package-manager.js.map
|
package/dist/package.js
CHANGED
package/dist/tsconfig.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TsConfigResult, TsConfigJson } from 'get-tsconfig';
|
|
2
|
-
export { TsConfigJson, TsConfigJsonResolved } from 'get-tsconfig';
|
|
2
|
+
export { TsConfigJson, TsConfigJsonResolved, TsConfigResult } from 'get-tsconfig';
|
|
3
3
|
import { W as WriteOptions } from './write-json-7d6e6751.js';
|
|
4
4
|
|
|
5
5
|
declare const findTSConfig: (cwd?: URL | string) => Promise<TsConfigResult>;
|
package/dist/tsconfig.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/package",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "One Package to rule them all, finds your root-dir, monorepo, package manager or tsconfig.json",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -122,26 +122,32 @@
|
|
|
122
122
|
"@anolilab/prettier-config": "^5.0.11",
|
|
123
123
|
"@anolilab/semantic-release-preset": "^8.0.0",
|
|
124
124
|
"@babel/core": "^7.23.2",
|
|
125
|
+
"@pnpm/exe": "^8.9.2",
|
|
125
126
|
"@rushstack/eslint-plugin-security": "^0.7.1",
|
|
126
127
|
"@total-typescript/ts-reset": "^0.5.1",
|
|
127
|
-
"@types/node": "18.
|
|
128
|
+
"@types/node": "18.18.5",
|
|
128
129
|
"@vitest/coverage-v8": "^0.34.6",
|
|
130
|
+
"cnpm": "^9.2.0",
|
|
129
131
|
"cross-env": "^7.0.3",
|
|
130
|
-
"eslint": "^8.
|
|
132
|
+
"eslint": "^8.52.0",
|
|
131
133
|
"eslint-plugin-deprecation": "^2.0.0",
|
|
132
134
|
"eslint-plugin-etc": "^2.0.3",
|
|
133
135
|
"eslint-plugin-import": "npm:eslint-plugin-i@^2.28.1",
|
|
134
136
|
"eslint-plugin-mdx": "^2.2.0",
|
|
135
137
|
"eslint-plugin-tsdoc": "^0.2.17",
|
|
136
|
-
"eslint-plugin-vitest": "^0.3.
|
|
138
|
+
"eslint-plugin-vitest": "^0.3.8",
|
|
137
139
|
"eslint-plugin-vitest-globals": "^1.4.0",
|
|
140
|
+
"execa": "^8.0.1",
|
|
141
|
+
"npm": "^10.2.1",
|
|
138
142
|
"prettier": "^3.0.3",
|
|
139
143
|
"rimraf": "^5.0.5",
|
|
140
144
|
"semantic-release": "^22.0.5",
|
|
141
145
|
"sort-package-json": "^2.6.0",
|
|
142
146
|
"tsup": "^7.2.0",
|
|
143
147
|
"typescript": "^5.2.2",
|
|
144
|
-
"vitest": "^0.34.6"
|
|
148
|
+
"vitest": "^0.34.6",
|
|
149
|
+
"which-pm-runs": "file:",
|
|
150
|
+
"yarn": "^1.22.19"
|
|
145
151
|
},
|
|
146
152
|
"engines": {
|
|
147
153
|
"node": ">=18.* <=20.*"
|
package/dist/chunk-HN5TULBQ.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { a, b } from './chunk-C7FQQQI6.js';
|
|
2
|
-
import { mkdir } from 'fs/promises';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
import { getTsconfig } from 'get-tsconfig';
|
|
5
|
-
|
|
6
|
-
var C=async t=>{let o=await getTsconfig(t===void 0?void 0:a(t),"tsconfig.json");if(o===null)throw new Error("Could not find tsconfig.json");return o},T=async(t,o={})=>{let n=a(o.cwd??process.cwd()),s=join(n,"tsconfig.json");await mkdir(n,{recursive:!0}),await b(s,t,o);};
|
|
7
|
-
|
|
8
|
-
export { C as a, T as b };
|
|
9
|
-
//# sourceMappingURL=out.js.map
|
|
10
|
-
//# sourceMappingURL=chunk-HN5TULBQ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tsconfig.ts"],"names":["mkdir","join","getTsconfig","findTSConfig","cwd","config","to_path_default","writeTSConfig","tsConfig","options","directory","path","writeJsonFile"],"mappings":"+CAAA,OAAS,SAAAA,MAAa,cACtB,OAAS,QAAAC,MAAY,OAGrB,OAAS,eAAAC,MAAmB,eAgBrB,IAAMC,EAAe,MAAOC,GAAgD,CAG/E,IAAMC,EAAS,MAAMH,EAAYE,IAAQ,OAAY,OAAYE,EAAOF,CAAG,EAAG,eAAe,EAE7F,GAAIC,IAAW,KACX,MAAM,IAAI,MAAM,8BAA8B,EAGlD,OAAOA,CACX,EAWaE,EAAgB,MAAOC,EAAwBC,EAAiD,CAAC,IAAqB,CAC/H,IAAMC,EAAYJ,EAAOG,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAC/CE,EAAOV,EAAKS,EAAW,eAAe,EAG5C,MAAMV,EAAMU,EAAW,CAAE,UAAW,EAAK,CAAC,EAE1C,MAAME,EAAcD,EAAMH,EAAUC,CAAO,CAC/C","sourcesContent":["import { mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport type { TsConfigJson, TsConfigResult } from \"get-tsconfig\";\nimport { getTsconfig } from \"get-tsconfig\";\n\nimport toPath from \"./utils/to-path\";\nimport type { WriteOptions } from \"./utils/write-json\";\nimport { writeJsonFile } from \"./utils/write-json\";\n\n/**\n * An asynchronous function that retrieves the TSConfig by searching for the \"tsconfig.json\" file from a given\n * current working directory.\n *\n * @param cwd - Optional. The current working directory from which to search for the \"tsconfig.json\" file.\n * The type of `cwd` is `string`.\n * @returns A `Promise` that resolves to the TSConfig result object.\n * The return type of the function is `Promise<TsConfigResult>`.\n * @throws An `Error` when the \"tsconfig.json\" file is not found.\n */\nexport const findTSConfig = async (cwd?: URL | string): Promise<TsConfigResult> => {\n // wrong typing in get-tsconfig\n // eslint-disable-next-line @typescript-eslint/await-thenable\n const config = await getTsconfig(cwd === undefined ? undefined : toPath(cwd), \"tsconfig.json\");\n\n if (config === null) {\n throw new Error(\"Could not find tsconfig.json\");\n }\n\n return config;\n};\n\n/**\n * An asynchronous function that writes the provided TypeScript configuration object to a tsconfig.json file.\n *\n * @param tsConfig - The TypeScript configuration object to write. The type of `tsConfig` is `TsConfigJson`.\n * @param options - Optional. The write options and the current working directory. The type of `options` is an\n * intersection type of `WriteOptions` and a Record type with an optional `cwd` key of type `string`.\n * @returns A `Promise` that resolves when the tsconfig.json file has been written.\n * The return type of function is `Promise<void>`.\n */\nexport const writeTSConfig = async (tsConfig: TsConfigJson, options: WriteOptions & { cwd?: URL | string } = {}): Promise<void> => {\n const directory = toPath(options.cwd ?? process.cwd());\n const path = join(directory, \"tsconfig.json\");\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await mkdir(directory, { recursive: true });\n\n await writeJsonFile(path, tsConfig, options);\n};\n\nexport type { TsConfigJson, TsConfigJsonResolved } from \"get-tsconfig\";\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/package-manager.ts"],"names":["execSync","existsSync","readFileSync","dirname","join","findUp","parsePackage","readPackage","lockFileNames","findLockFile","cwd","filePath","findPackageManager","foundFile","directory","lockFile","lockFileName","packageJsonFilePath","packageJson","foundPackageManager","prefix","getPackageManagerVersion","name"],"mappings":"AAAA,OAAS,YAAAA,MAAgB,gBACzB,OAAS,cAAAC,EAAY,gBAAAC,MAAoB,KACzC,OAAS,WAAAC,EAAS,QAAAC,MAAY,OAG9B,OAAS,UAAAC,MAAc,UACvB,OAAS,gBAAAC,EAAc,eAAAC,MAAmB,WAE1C,IAAMC,EAAgB,CAAC,YAAa,oBAAqB,iBAAkB,sBAAuB,WAAW,EAWhGC,EAAe,MAAOC,GAA0C,CACzE,IAAMC,EAAW,MAAMN,EAAOG,EAAe,CACzC,cAAe,GACf,KAAM,OACN,GAAIE,GAAO,CAAE,IAAAA,CAAI,CACrB,CAAC,EAED,GAAI,CAAC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B,MAAO,CACH,eAAgB,MAChB,KAAMV,EAAQU,CAAS,CAC3B,EAGJ,MAAM,IAAI,MAAM,0BAA0B,CAC9C,EAQaQ,EAA4BC,GAAyBtB,EAAS,GAAGsB,CAAI,YAAY,EAAE,SAAS,MAAM,EAAE,KAAK","sourcesContent":["import { execSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\nimport type { Options } from \"find-up\";\nimport { findUp } from \"find-up\";\nimport { parsePackage, readPackage } from \"read-pkg\";\n\nconst lockFileNames = [\"yarn.lock\", \"package-lock.json\", \"pnpm-lock.yaml\", \"npm-shrinkwrap.json\", \"bun.lockb\"] as const;\n\n/**\n * An asynchronous function that finds a lock file in the specified directory or any of its parent directories.\n *\n * @param cwd - Optional. The directory path to start the search from. The type of `cwd` is part of an `Options` type,\n * specifically `Options[\"cwd\"]`. Defaults to the current working directory.\n * @returns A `Promise` that resolves with the path of the found lock file.\n * The type of the returned promise is `Promise<string>`.\n * @throws An `Error` if no lock file is found.\n */\nexport const findLockFile = async (cwd?: Options[\"cwd\"]): Promise<string> => {\n const filePath = await findUp(lockFileNames, {\n allowSymlinks: false,\n type: \"file\",\n ...(cwd && { cwd }),\n });\n\n if (!filePath) {\n throw new Error(\"Could not find lock file\");\n }\n\n return filePath;\n};\n\nexport type PackageManager = \"bun\" | \"npm\" | \"pnpm\" | \"yarn\";\n\nexport type PackageManagerResult = {\n packageManager: PackageManager;\n path: string;\n};\n\n/**\n * An asynchronous function that finds the package manager used in a project based on the presence of lock files\n * or package.json configuration. If found, it returns the package manager and the path to the lock file or package.json.\n * Throws an error if no lock file or package.json is found.\n *\n * @param cwd - Optional. The current working directory to start the search from. The type of `cwd` is part of an `Options`\n * type, specifically `Options[\"cwd\"]`.\n * @returns A `Promise` that resolves to an object containing the package manager and path.\n * The return type of the function is `Promise<PackageManagerResult>`.\n * @throws An `Error` if no lock file or package.json is found.\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport const findPackageManager = async (cwd?: Options[\"cwd\"]): Promise<PackageManagerResult> => {\n const foundFile = await findUp(\n (directory) => {\n let lockFile: string | undefined;\n\n lockFileNames.forEach((lockFileName) => {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!lockFile && existsSync(join(directory, lockFileName))) {\n lockFile = join(directory, lockFileName);\n }\n });\n\n if (lockFile) {\n return lockFile;\n }\n\n const packageJsonFilePath = join(directory, \"package.json\");\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(packageJsonFilePath)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const packageJson = parsePackage(readFileSync(packageJsonFilePath, \"utf8\"));\n\n if (packageJson.packageManager !== undefined) {\n return packageJsonFilePath;\n }\n }\n\n return undefined;\n },\n {\n ...(cwd && { cwd }),\n allowSymlinks: false,\n },\n );\n\n if (!foundFile) {\n throw new Error(\"Could not find lock file\");\n }\n\n if (foundFile.endsWith(\"package.json\")) {\n const packageJson = await readPackage({ cwd: dirname(foundFile), normalize: true });\n\n if (packageJson.packageManager) {\n const packageManagerNames = [\"npm\", \"yarn\", \"pnpm\", \"bun\"] as const;\n const foundPackageManager = packageManagerNames.find((prefix) => (packageJson.packageManager as string).startsWith(prefix));\n\n if (foundPackageManager) {\n return {\n packageManager: foundPackageManager,\n path: dirname(foundFile),\n };\n }\n }\n }\n\n if (foundFile.endsWith(\"yarn.lock\")) {\n return {\n packageManager: \"yarn\",\n path: dirname(foundFile),\n };\n }\n\n if (foundFile.endsWith(\"package-lock.json\") || foundFile.endsWith(\"npm-shrinkwrap.json\")) {\n return {\n packageManager: \"npm\",\n path: dirname(foundFile),\n };\n }\n\n if (foundFile.endsWith(\"pnpm-lock.yaml\")) {\n return {\n packageManager: \"pnpm\",\n path: dirname(foundFile),\n };\n }\n\n if (foundFile.endsWith(\"bun.lockb\")) {\n return {\n packageManager: \"bun\",\n path: dirname(foundFile),\n };\n }\n\n throw new Error(\"Could not find lock file\");\n};\n\n/**\n * Function that retrieves the version of the specified package manager.\n *\n * @param name - The name of the package manager. The type of `name` is `string`.\n * @returns The version of the package manager. The return type of the function is `string`.\n */\nexport const getPackageManagerVersion = (name: string): string => execSync(`${name} --version`).toString(\"utf8\").trim();\n"]}
|
|
File without changes
|
|
File without changes
|