@stryke/env 0.20.49 → 0.20.51
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 +16 -0
- package/dist/_virtual/rolldown_runtime.cjs +29 -1
- package/dist/ci-checks.cjs +23 -1
- package/dist/ci-checks.mjs +21 -1
- package/dist/ci-checks.mjs.map +1 -1
- package/dist/convert/src/to-array.cjs +15 -1
- package/dist/convert/src/to-array.mjs +14 -1
- package/dist/convert/src/to-array.mjs.map +1 -1
- package/dist/environment-checks.cjs +156 -1
- package/dist/environment-checks.mjs +139 -1
- package/dist/environment-checks.mjs.map +1 -1
- package/dist/fs/src/exists.cjs +17 -1
- package/dist/fs/src/exists.mjs +15 -1
- package/dist/fs/src/exists.mjs.map +1 -1
- package/dist/fs/src/read-file.cjs +17 -1
- package/dist/fs/src/read-file.mjs +16 -1
- package/dist/fs/src/read-file.mjs.map +1 -1
- package/dist/get-env-paths.cjs +87 -1
- package/dist/get-env-paths.mjs +84 -1
- package/dist/get-env-paths.mjs.map +1 -1
- package/dist/index.cjs +48 -1
- package/dist/index.mjs +9 -1
- package/dist/load-env.cjs +124 -1
- package/dist/load-env.mjs +118 -1
- package/dist/load-env.mjs.map +1 -1
- package/dist/path/src/is-type.cjs +28 -1
- package/dist/path/src/is-type.mjs +28 -1
- package/dist/path/src/is-type.mjs.map +1 -1
- package/dist/path/src/join-paths.cjs +106 -1
- package/dist/path/src/join-paths.mjs +106 -1
- package/dist/path/src/join-paths.mjs.map +1 -1
- package/dist/path/src/regex.cjs +12 -1
- package/dist/path/src/regex.mjs +8 -1
- package/dist/path/src/regex.mjs.map +1 -1
- package/dist/path/src/slash.cjs +15 -1
- package/dist/path/src/slash.mjs +14 -1
- package/dist/path/src/slash.mjs.map +1 -1
- package/dist/providers.cjs +112 -1
- package/dist/providers.mjs +110 -1
- package/dist/providers.mjs.map +1 -1
- package/dist/runtime-checks.cjs +71 -1
- package/dist/runtime-checks.mjs +60 -1
- package/dist/runtime-checks.mjs.map +1 -1
- package/dist/string-format/src/acronyms.cjs +408 -1
- package/dist/string-format/src/acronyms.mjs +407 -1
- package/dist/string-format/src/acronyms.mjs.map +1 -1
- package/dist/string-format/src/articles.cjs +10 -1
- package/dist/string-format/src/articles.mjs +9 -1
- package/dist/string-format/src/articles.mjs.map +1 -1
- package/dist/string-format/src/combine.cjs +15 -1
- package/dist/string-format/src/combine.mjs +14 -1
- package/dist/string-format/src/combine.mjs.map +1 -1
- package/dist/string-format/src/conjunctions.cjs +32 -1
- package/dist/string-format/src/conjunctions.mjs +31 -1
- package/dist/string-format/src/conjunctions.mjs.map +1 -1
- package/dist/string-format/src/decamelize.cjs +14 -1
- package/dist/string-format/src/decamelize.mjs +13 -1
- package/dist/string-format/src/decamelize.mjs.map +1 -1
- package/dist/string-format/src/format-special-cases.cjs +33 -1
- package/dist/string-format/src/format-special-cases.mjs +33 -1
- package/dist/string-format/src/format-special-cases.mjs.map +1 -1
- package/dist/string-format/src/prepositions.cjs +68 -1
- package/dist/string-format/src/prepositions.mjs +67 -1
- package/dist/string-format/src/prepositions.mjs.map +1 -1
- package/dist/string-format/src/special-cases.cjs +53 -1
- package/dist/string-format/src/special-cases.mjs +52 -1
- package/dist/string-format/src/special-cases.mjs.map +1 -1
- package/dist/string-format/src/title-case.cjs +19 -1
- package/dist/string-format/src/title-case.mjs +19 -1
- package/dist/string-format/src/title-case.mjs.map +1 -1
- package/dist/string-format/src/upper-case-first.cjs +17 -1
- package/dist/string-format/src/upper-case-first.mjs +16 -1
- package/dist/string-format/src/upper-case-first.mjs.map +1 -1
- package/dist/types.cjs +13 -1
- package/dist/types.mjs +12 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +6 -6
package/dist/load-env.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-env.mjs","names":["envDir","env: DotenvParseOutput","prefix"],"sources":["../src/load-env.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { DotenvPopulateInput } from \"@dotenvx/dotenvx\";\nimport { parse } from \"@dotenvx/dotenvx\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { readFile } from \"@stryke/fs/read-file\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport defu from \"defu\";\nimport type { DotenvParseOutput } from \"./types\";\nimport { ENV_PREFIXES } from \"./types\";\n\nexport function getEnvFilesForMode(\n envDir: string,\n mode = \"production\"\n): string[] {\n return [\n /** default file */ \".env\",\n /** local file */ \".env.local\",\n /** mode file */ `.env.${mode}`,\n /** mode local file */ `.env.${mode}.local`,\n /** local mode file */ `.env.local.${mode}`\n ].map(file => joinPaths(envDir, file));\n}\n\n/**\n * Load environment variables from a .env file.\n *\n * @param envFile - The path to the .env file.\n * @returns The environment variables.\n */\nexport async function loadEnvFile(\n envFile: string,\n envDir: string | string[] = []\n): Promise<DotenvParseOutput> {\n const envDirs = Array.isArray(envDir) ? envDir : [envDir];\n\n return (\n await Promise.all(\n (envDir.length > 0\n ? envDirs.map(envDir => joinPaths(envDir, envFile))\n : [envFile]\n ).map(async envFilePath => {\n if (!existsSync(envFilePath)) {\n return undefined;\n }\n\n return readFile(envFilePath);\n })\n )\n ).reduce((ret, envFileContent) => {\n if (!envFileContent) {\n return ret;\n }\n\n const result = parse(envFileContent, {\n processEnv: { ...process.env } as DotenvPopulateInput,\n privateKey:\n process.env.DOTENV_PRIVATE_KEY || process.env.STORM_PRIVATE_KEY\n });\n\n return defu(result, ret);\n }, {});\n}\n\n/**\n * Load environment variables from .env files.\n *\n * @remarks\n * This function loads environment variables from .env files based on the mode. For the `production` mode, it will load:\n * - `.env`\n * - `.env.local`\n * - `.env.production`\n * - `.env.production.local`\n *\n * @param envDir - The directory/directories to load the environment variables from.\n * @param mode - The mode to load the environment variables for.\n * @param prefix - The prefix or prefixes to use for the environment variables.\n * @returns The environment variables.\n */\nexport async function loadEnv(\n envDir: string | string[],\n mode?: string,\n prefix?: string | string[]\n): Promise<DotenvParseOutput> {\n if (mode === \"local\") {\n throw new Error(\n '\"local\" cannot be used as a mode name because it conflicts with ' +\n \"the .local postfix for .env files.\"\n );\n }\n\n const prefixes = toArray(prefix).reduce((ret, pre) => {\n if (!pre) {\n return ret;\n }\n\n if (!ret.includes(pre.endsWith(\"_\") ? pre : `${pre}_`)) {\n ret.push(pre.endsWith(\"_\") ? pre : `${pre}_`);\n }\n if (!ret.includes(`${pre.endsWith(\"_\") ? pre : `${pre}_`}PUBLIC_`)) {\n ret.push(`${pre.endsWith(\"_\") ? pre : `${pre}_`}PUBLIC_`);\n }\n return ret;\n }, [] as string[]);\n const envDirs = Array.isArray(envDir) ? envDir : [envDir];\n\n const env: DotenvParseOutput = {};\n const envFiles = envDirs.reduce((ret, envFilePath) => {\n ret.push(\n ...getEnvFilesForMode(envFilePath, mode).filter(\n envFile => !ret.includes(envFile)\n )\n );\n\n return ret;\n }, [] as string[]);\n\n let envParsed = (\n await Promise.all(\n envFiles.map(async filePath => {\n return loadEnvFile(filePath);\n })\n )\n ).reduce((ret, result) => {\n return defu(result, ret);\n }, {});\n\n // test NODE_ENV override before expand as otherwise process.env.NODE_ENV would override this\n if (envParsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === undefined) {\n process.env.VITE_USER_NODE_ENV = JSON.stringify(envParsed.NODE_ENV);\n }\n // support BROWSER and BROWSER_ARGS env variables\n if (envParsed.BROWSER && process.env.BROWSER === undefined) {\n process.env.BROWSER = JSON.stringify(envParsed.BROWSER);\n }\n if (envParsed.BROWSER_ARGS && process.env.BROWSER_ARGS === undefined) {\n process.env.BROWSER_ARGS = JSON.stringify(envParsed.BROWSER_ARGS);\n }\n\n // let environment variables use each other. make a copy of `process.env` so that we do not mutate the global `process.env`.\n envParsed = defu({ ...process.env }, envParsed);\n if (prefixes.length === 0) {\n return envParsed;\n }\n\n // only keys that start with prefix are exposed to client\n for (const [key, value] of Object.entries(envParsed)) {\n if (prefixes.some(prefix => key.startsWith(prefix))) {\n env[key] = String(value);\n }\n }\n\n // check if there are actual env variables starting with VITE_*\n // these are typically provided inline and should be prioritized\n for (const key in process.env) {\n if (prefixes.some(prefix => key.startsWith(prefix))) {\n env[key] = process.env[key] as string;\n }\n }\n\n return env;\n}\n\n/**\n * Load environment variables from .env files for a client-side environment.\n *\n * @remarks\n * This function loads environment variables from .env files based on the mode. For the `production` mode, it will load:\n * - `.env`\n * - `.env.local`\n * - `.env.production`\n * - `.env.production.local`\n *\n * @param envDir - The directory/directories to load the environment variables from.\n * @param mode - The mode to load the environment variables for.\n * @param prefix - The prefix or prefixes to use for the environment variables.\n * @returns The environment variables.\n */\nexport async function loadClientEnv(\n envDir: string | string[],\n mode?: string,\n prefix: string | string[] = ENV_PREFIXES\n): Promise<DotenvParseOutput> {\n return loadEnv(envDir, mode, prefix);\n}\n\n/**\n * Load environment variables from .env files for a server-side environment.\n *\n * @remarks\n * This function loads environment variables from .env files based on the mode. For the `production` mode, it will load:\n * - `.env`\n * - `.env.local`\n * - `.env.production`\n * - `.env.production.local`\n *\n * @param envDir - The directory/directories to load the environment variables from.\n * @param mode - The mode to load the environment variables for.\n * @returns The environment variables.\n */\nexport async function loadServerEnv(\n envDir: string | string[],\n mode: string\n): Promise<DotenvParseOutput> {\n return loadEnv(envDir, mode);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"load-env.mjs","names":["envDir","env: DotenvParseOutput","prefix"],"sources":["../src/load-env.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { DotenvPopulateInput } from \"@dotenvx/dotenvx\";\nimport { parse } from \"@dotenvx/dotenvx\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { readFile } from \"@stryke/fs/read-file\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport defu from \"defu\";\nimport type { DotenvParseOutput } from \"./types\";\nimport { ENV_PREFIXES } from \"./types\";\n\nexport function getEnvFilesForMode(\n envDir: string,\n mode = \"production\"\n): string[] {\n return [\n /** default file */ \".env\",\n /** local file */ \".env.local\",\n /** mode file */ `.env.${mode}`,\n /** mode local file */ `.env.${mode}.local`,\n /** local mode file */ `.env.local.${mode}`\n ].map(file => joinPaths(envDir, file));\n}\n\n/**\n * Load environment variables from a .env file.\n *\n * @param envFile - The path to the .env file.\n * @returns The environment variables.\n */\nexport async function loadEnvFile(\n envFile: string,\n envDir: string | string[] = []\n): Promise<DotenvParseOutput> {\n const envDirs = Array.isArray(envDir) ? envDir : [envDir];\n\n return (\n await Promise.all(\n (envDir.length > 0\n ? envDirs.map(envDir => joinPaths(envDir, envFile))\n : [envFile]\n ).map(async envFilePath => {\n if (!existsSync(envFilePath)) {\n return undefined;\n }\n\n return readFile(envFilePath);\n })\n )\n ).reduce((ret, envFileContent) => {\n if (!envFileContent) {\n return ret;\n }\n\n const result = parse(envFileContent, {\n processEnv: { ...process.env } as DotenvPopulateInput,\n privateKey:\n process.env.DOTENV_PRIVATE_KEY || process.env.STORM_PRIVATE_KEY\n });\n\n return defu(result, ret);\n }, {});\n}\n\n/**\n * Load environment variables from .env files.\n *\n * @remarks\n * This function loads environment variables from .env files based on the mode. For the `production` mode, it will load:\n * - `.env`\n * - `.env.local`\n * - `.env.production`\n * - `.env.production.local`\n *\n * @param envDir - The directory/directories to load the environment variables from.\n * @param mode - The mode to load the environment variables for.\n * @param prefix - The prefix or prefixes to use for the environment variables.\n * @returns The environment variables.\n */\nexport async function loadEnv(\n envDir: string | string[],\n mode?: string,\n prefix?: string | string[]\n): Promise<DotenvParseOutput> {\n if (mode === \"local\") {\n throw new Error(\n '\"local\" cannot be used as a mode name because it conflicts with ' +\n \"the .local postfix for .env files.\"\n );\n }\n\n const prefixes = toArray(prefix).reduce((ret, pre) => {\n if (!pre) {\n return ret;\n }\n\n if (!ret.includes(pre.endsWith(\"_\") ? pre : `${pre}_`)) {\n ret.push(pre.endsWith(\"_\") ? pre : `${pre}_`);\n }\n if (!ret.includes(`${pre.endsWith(\"_\") ? pre : `${pre}_`}PUBLIC_`)) {\n ret.push(`${pre.endsWith(\"_\") ? pre : `${pre}_`}PUBLIC_`);\n }\n return ret;\n }, [] as string[]);\n const envDirs = Array.isArray(envDir) ? envDir : [envDir];\n\n const env: DotenvParseOutput = {};\n const envFiles = envDirs.reduce((ret, envFilePath) => {\n ret.push(\n ...getEnvFilesForMode(envFilePath, mode).filter(\n envFile => !ret.includes(envFile)\n )\n );\n\n return ret;\n }, [] as string[]);\n\n let envParsed = (\n await Promise.all(\n envFiles.map(async filePath => {\n return loadEnvFile(filePath);\n })\n )\n ).reduce((ret, result) => {\n return defu(result, ret);\n }, {});\n\n // test NODE_ENV override before expand as otherwise process.env.NODE_ENV would override this\n if (envParsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === undefined) {\n process.env.VITE_USER_NODE_ENV = JSON.stringify(envParsed.NODE_ENV);\n }\n // support BROWSER and BROWSER_ARGS env variables\n if (envParsed.BROWSER && process.env.BROWSER === undefined) {\n process.env.BROWSER = JSON.stringify(envParsed.BROWSER);\n }\n if (envParsed.BROWSER_ARGS && process.env.BROWSER_ARGS === undefined) {\n process.env.BROWSER_ARGS = JSON.stringify(envParsed.BROWSER_ARGS);\n }\n\n // let environment variables use each other. make a copy of `process.env` so that we do not mutate the global `process.env`.\n envParsed = defu({ ...process.env }, envParsed);\n if (prefixes.length === 0) {\n return envParsed;\n }\n\n // only keys that start with prefix are exposed to client\n for (const [key, value] of Object.entries(envParsed)) {\n if (prefixes.some(prefix => key.startsWith(prefix))) {\n env[key] = String(value);\n }\n }\n\n // check if there are actual env variables starting with VITE_*\n // these are typically provided inline and should be prioritized\n for (const key in process.env) {\n if (prefixes.some(prefix => key.startsWith(prefix))) {\n env[key] = process.env[key] as string;\n }\n }\n\n return env;\n}\n\n/**\n * Load environment variables from .env files for a client-side environment.\n *\n * @remarks\n * This function loads environment variables from .env files based on the mode. For the `production` mode, it will load:\n * - `.env`\n * - `.env.local`\n * - `.env.production`\n * - `.env.production.local`\n *\n * @param envDir - The directory/directories to load the environment variables from.\n * @param mode - The mode to load the environment variables for.\n * @param prefix - The prefix or prefixes to use for the environment variables.\n * @returns The environment variables.\n */\nexport async function loadClientEnv(\n envDir: string | string[],\n mode?: string,\n prefix: string | string[] = ENV_PREFIXES\n): Promise<DotenvParseOutput> {\n return loadEnv(envDir, mode, prefix);\n}\n\n/**\n * Load environment variables from .env files for a server-side environment.\n *\n * @remarks\n * This function loads environment variables from .env files based on the mode. For the `production` mode, it will load:\n * - `.env`\n * - `.env.local`\n * - `.env.production`\n * - `.env.production.local`\n *\n * @param envDir - The directory/directories to load the environment variables from.\n * @param mode - The mode to load the environment variables for.\n * @returns The environment variables.\n */\nexport async function loadServerEnv(\n envDir: string | string[],\n mode: string\n): Promise<DotenvParseOutput> {\n return loadEnv(envDir, mode);\n}\n"],"mappings":";;;;;;;;;AA4BA,SAAgB,mBACd,QACA,OAAO,cACG;AACV,QAAO;EACe;EACF;EACD,QAAQ;EACF,QAAQ,KAAK;EACb,cAAc;EACtC,CAAC,KAAI,SAAQ,UAAU,QAAQ,KAAK,CAAC;;;;;;;;AASxC,eAAsB,YACpB,SACA,SAA4B,EAAE,EACF;CAC5B,MAAM,UAAU,MAAM,QAAQ,OAAO,GAAG,SAAS,CAAC,OAAO;AAEzD,SACE,MAAM,QAAQ,KACX,OAAO,SAAS,IACb,QAAQ,KAAI,aAAU,UAAUA,UAAQ,QAAQ,CAAC,GACjD,CAAC,QAAQ,EACX,IAAI,OAAM,gBAAe;AACzB,MAAI,CAAC,WAAW,YAAY,CAC1B;AAGF,SAAO,SAAS,YAAY;GAC5B,CACH,EACD,QAAQ,KAAK,mBAAmB;AAChC,MAAI,CAAC,eACH,QAAO;AAST,SAAO,KANQ,MAAM,gBAAgB;GACnC,YAAY,EAAE,GAAG,QAAQ,KAAK;GAC9B,YACE,QAAQ,IAAI,sBAAsB,QAAQ,IAAI;GACjD,CAAC,EAEkB,IAAI;IACvB,EAAE,CAAC;;;;;;;;;;;;;;;;;AAkBR,eAAsB,QACpB,QACA,MACA,QAC4B;AAC5B,KAAI,SAAS,QACX,OAAM,IAAI,MACR,uGAED;CAGH,MAAM,WAAW,QAAQ,OAAO,CAAC,QAAQ,KAAK,QAAQ;AACpD,MAAI,CAAC,IACH,QAAO;AAGT,MAAI,CAAC,IAAI,SAAS,IAAI,SAAS,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,CACpD,KAAI,KAAK,IAAI,SAAS,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG;AAE/C,MAAI,CAAC,IAAI,SAAS,GAAG,IAAI,SAAS,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAChE,KAAI,KAAK,GAAG,IAAI,SAAS,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS;AAE3D,SAAO;IACN,EAAE,CAAa;CAClB,MAAM,UAAU,MAAM,QAAQ,OAAO,GAAG,SAAS,CAAC,OAAO;CAEzD,MAAMC,MAAyB,EAAE;CACjC,MAAM,WAAW,QAAQ,QAAQ,KAAK,gBAAgB;AACpD,MAAI,KACF,GAAG,mBAAmB,aAAa,KAAK,CAAC,QACvC,YAAW,CAAC,IAAI,SAAS,QAAQ,CAClC,CACF;AAED,SAAO;IACN,EAAE,CAAa;CAElB,IAAI,aACF,MAAM,QAAQ,IACZ,SAAS,IAAI,OAAM,aAAY;AAC7B,SAAO,YAAY,SAAS;GAC5B,CACH,EACD,QAAQ,KAAK,WAAW;AACxB,SAAO,KAAK,QAAQ,IAAI;IACvB,EAAE,CAAC;AAGN,KAAI,UAAU,YAAY,QAAQ,IAAI,uBAAuB,OAC3D,SAAQ,IAAI,qBAAqB,KAAK,UAAU,UAAU,SAAS;AAGrE,KAAI,UAAU,WAAW,QAAQ,IAAI,YAAY,OAC/C,SAAQ,IAAI,UAAU,KAAK,UAAU,UAAU,QAAQ;AAEzD,KAAI,UAAU,gBAAgB,QAAQ,IAAI,iBAAiB,OACzD,SAAQ,IAAI,eAAe,KAAK,UAAU,UAAU,aAAa;AAInE,aAAY,KAAK,EAAE,GAAG,QAAQ,KAAK,EAAE,UAAU;AAC/C,KAAI,SAAS,WAAW,EACtB,QAAO;AAIT,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,UAAU,CAClD,KAAI,SAAS,MAAK,aAAU,IAAI,WAAWC,SAAO,CAAC,CACjD,KAAI,OAAO,OAAO,MAAM;AAM5B,MAAK,MAAM,OAAO,QAAQ,IACxB,KAAI,SAAS,MAAK,aAAU,IAAI,WAAWA,SAAO,CAAC,CACjD,KAAI,OAAO,QAAQ,IAAI;AAI3B,QAAO;;;;;;;;;;;;;;;;;AAkBT,eAAsB,cACpB,QACA,MACA,SAA4B,cACA;AAC5B,QAAO,QAAQ,QAAQ,MAAM,OAAO;;;;;;;;;;;;;;;;AAiBtC,eAAsB,cACpB,QACA,MAC4B;AAC5B,QAAO,QAAQ,QAAQ,KAAK"}
|
|
@@ -1 +1,28 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_regex = require('./regex.cjs');
|
|
2
|
+
const require_slash = require('./slash.cjs');
|
|
3
|
+
|
|
4
|
+
//#region ../path/src/is-type.ts
|
|
5
|
+
/**
|
|
6
|
+
* Check if the path is an absolute path.
|
|
7
|
+
*
|
|
8
|
+
* @param path - The path to check
|
|
9
|
+
* @returns An indicator specifying if the path is an absolute path
|
|
10
|
+
*/
|
|
11
|
+
function isAbsolutePath(path) {
|
|
12
|
+
return require_regex.ABSOLUTE_PATH_REGEX.test(require_slash.slash(path));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Check if the path is an absolute path.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* This is an alias for {@link isAbsolutePath}.
|
|
19
|
+
*
|
|
20
|
+
* @param path - The path to check
|
|
21
|
+
* @returns An indicator specifying if the path is an absolute path
|
|
22
|
+
*/
|
|
23
|
+
function isAbsolute(path) {
|
|
24
|
+
return isAbsolutePath(path);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.isAbsolute = isAbsolute;
|
|
@@ -1,2 +1,29 @@
|
|
|
1
|
-
import{ABSOLUTE_PATH_REGEX
|
|
1
|
+
import { ABSOLUTE_PATH_REGEX } from "./regex.mjs";
|
|
2
|
+
import { slash } from "./slash.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../path/src/is-type.ts
|
|
5
|
+
/**
|
|
6
|
+
* Check if the path is an absolute path.
|
|
7
|
+
*
|
|
8
|
+
* @param path - The path to check
|
|
9
|
+
* @returns An indicator specifying if the path is an absolute path
|
|
10
|
+
*/
|
|
11
|
+
function isAbsolutePath(path) {
|
|
12
|
+
return ABSOLUTE_PATH_REGEX.test(slash(path));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Check if the path is an absolute path.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* This is an alias for {@link isAbsolutePath}.
|
|
19
|
+
*
|
|
20
|
+
* @param path - The path to check
|
|
21
|
+
* @returns An indicator specifying if the path is an absolute path
|
|
22
|
+
*/
|
|
23
|
+
function isAbsolute(path) {
|
|
24
|
+
return isAbsolutePath(path);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { isAbsolute };
|
|
2
29
|
//# sourceMappingURL=is-type.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-type.mjs","names":[],"sources":["../../../../path/src/is-type.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { ABSOLUTE_PATH_REGEX, NPM_SCOPED_PACKAGE_REGEX } from \"./regex\";\nimport { slash } from \"./slash\";\n\n/**\n * Check if the path is an absolute path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is an absolute path\n */\nexport function isAbsolutePath(path: string): boolean {\n return ABSOLUTE_PATH_REGEX.test(slash(path));\n}\n\n/**\n * Check if the path is an absolute path.\n *\n * @remarks\n * This is an alias for {@link isAbsolutePath}.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is an absolute path\n */\nexport function isAbsolute(path: string): boolean {\n return isAbsolutePath(path);\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function isRelativePath(path: string): boolean {\n return !isAbsolutePath(path);\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @remarks\n * This is an alias for {@link isRelativePath}.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function isRelative(path: string): boolean {\n return isRelativePath(path);\n}\n\n/**\n * Check if the path is a npm package path.\n *\n * @remarks\n * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackage}.\n *\n * @example\n * ```ts\n * isNpmScopedPackage(\"@stryke/path\"); // returns true\n * isNpmScopedPackage(\"lodash\"); // returns false\n * isNpmNamespacePackage(\"./src/index.ts\"); // returns false\n * ```\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a npm package path\n */\nexport function isNpmScopedPackagePath(path: string): boolean {\n return NPM_SCOPED_PACKAGE_REGEX.test(slash(path));\n}\n\n/**\n * Check if the path is a npm package path.\n *\n * @remarks\n * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackagePath}.\n *\n * @example\n * ```ts\n * isNpmScopedPackagePath(\"@stryke/path\"); // returns true\n * isNpmScopedPackagePath(\"lodash\"); // returns false\n * isNpmScopedPackagePath(\"./src/index.ts\"); // returns false\n * ```\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a npm package path\n */\nexport function isNpmScopedPackage(path: string): boolean {\n return isNpmScopedPackagePath(path);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-type.mjs","names":[],"sources":["../../../../path/src/is-type.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { ABSOLUTE_PATH_REGEX, NPM_SCOPED_PACKAGE_REGEX } from \"./regex\";\nimport { slash } from \"./slash\";\n\n/**\n * Check if the path is an absolute path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is an absolute path\n */\nexport function isAbsolutePath(path: string): boolean {\n return ABSOLUTE_PATH_REGEX.test(slash(path));\n}\n\n/**\n * Check if the path is an absolute path.\n *\n * @remarks\n * This is an alias for {@link isAbsolutePath}.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is an absolute path\n */\nexport function isAbsolute(path: string): boolean {\n return isAbsolutePath(path);\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function isRelativePath(path: string): boolean {\n return !isAbsolutePath(path);\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @remarks\n * This is an alias for {@link isRelativePath}.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function isRelative(path: string): boolean {\n return isRelativePath(path);\n}\n\n/**\n * Check if the path is a npm package path.\n *\n * @remarks\n * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackage}.\n *\n * @example\n * ```ts\n * isNpmScopedPackage(\"@stryke/path\"); // returns true\n * isNpmScopedPackage(\"lodash\"); // returns false\n * isNpmNamespacePackage(\"./src/index.ts\"); // returns false\n * ```\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a npm package path\n */\nexport function isNpmScopedPackagePath(path: string): boolean {\n return NPM_SCOPED_PACKAGE_REGEX.test(slash(path));\n}\n\n/**\n * Check if the path is a npm package path.\n *\n * @remarks\n * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackagePath}.\n *\n * @example\n * ```ts\n * isNpmScopedPackagePath(\"@stryke/path\"); // returns true\n * isNpmScopedPackagePath(\"lodash\"); // returns false\n * isNpmScopedPackagePath(\"./src/index.ts\"); // returns false\n * ```\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a npm package path\n */\nexport function isNpmScopedPackage(path: string): boolean {\n return isNpmScopedPackagePath(path);\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,eAAe,MAAuB;AACpD,QAAO,oBAAoB,KAAK,MAAM,KAAK,CAAC;;;;;;;;;;;AAY9C,SAAgB,WAAW,MAAuB;AAChD,QAAO,eAAe,KAAK"}
|
|
@@ -1 +1,106 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_regex = require('./regex.cjs');
|
|
2
|
+
const require_is_type = require('./is-type.cjs');
|
|
3
|
+
|
|
4
|
+
//#region ../path/src/join-paths.ts
|
|
5
|
+
function normalizeWindowsPath(input = "") {
|
|
6
|
+
if (!input) return input;
|
|
7
|
+
return input.replace(/\\/g, "/").replace(require_regex.DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
|
|
8
|
+
}
|
|
9
|
+
function correctPaths(path) {
|
|
10
|
+
if (!path || path.length === 0) return ".";
|
|
11
|
+
path = normalizeWindowsPath(path);
|
|
12
|
+
const isUNCPath = path.match(require_regex.UNC_REGEX);
|
|
13
|
+
const isPathAbsolute = require_is_type.isAbsolute(path);
|
|
14
|
+
const trailingSeparator = path[path.length - 1] === "/";
|
|
15
|
+
path = normalizeString(path, !isPathAbsolute);
|
|
16
|
+
if (path.length === 0) {
|
|
17
|
+
if (isPathAbsolute) return "/";
|
|
18
|
+
return trailingSeparator ? "./" : ".";
|
|
19
|
+
}
|
|
20
|
+
if (trailingSeparator) path += "/";
|
|
21
|
+
if (require_regex.DRIVE_LETTER_REGEX.test(path)) path += "/";
|
|
22
|
+
if (isUNCPath) {
|
|
23
|
+
if (!isPathAbsolute) return `//./${path}`;
|
|
24
|
+
return `//${path}`;
|
|
25
|
+
}
|
|
26
|
+
return isPathAbsolute && !require_is_type.isAbsolute(path) ? `/${path}` : path;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Joins all given path segments together using the platform-specific separator as a delimiter.
|
|
30
|
+
* The resulting path is normalized to remove any redundant or unnecessary segments.
|
|
31
|
+
*
|
|
32
|
+
* @param segments - The path segments to join.
|
|
33
|
+
* @returns The joined and normalized path string.
|
|
34
|
+
*/
|
|
35
|
+
function joinPaths(...segments) {
|
|
36
|
+
let path = "";
|
|
37
|
+
for (const seg of segments) {
|
|
38
|
+
if (!seg) continue;
|
|
39
|
+
if (path.length > 0) {
|
|
40
|
+
const pathTrailing = path[path.length - 1] === "/";
|
|
41
|
+
const segLeading = seg[0] === "/";
|
|
42
|
+
if (pathTrailing && segLeading) path += seg.slice(1);
|
|
43
|
+
else path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
44
|
+
} else path += seg;
|
|
45
|
+
}
|
|
46
|
+
return correctPaths(path);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
|
|
50
|
+
*
|
|
51
|
+
* @param path - The path to normalize.
|
|
52
|
+
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
|
|
53
|
+
* @returns the normalized path string.
|
|
54
|
+
*/
|
|
55
|
+
function normalizeString(path, allowAboveRoot) {
|
|
56
|
+
let res = "";
|
|
57
|
+
let lastSegmentLength = 0;
|
|
58
|
+
let lastSlash = -1;
|
|
59
|
+
let dots = 0;
|
|
60
|
+
let char = null;
|
|
61
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
62
|
+
if (index < path.length) char = path[index];
|
|
63
|
+
else if (char === "/") break;
|
|
64
|
+
else char = "/";
|
|
65
|
+
if (char === "/") {
|
|
66
|
+
if (lastSlash === index - 1 || dots === 1) {} else if (dots === 2) {
|
|
67
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
68
|
+
if (res.length > 2) {
|
|
69
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
70
|
+
if (lastSlashIndex === -1) {
|
|
71
|
+
res = "";
|
|
72
|
+
lastSegmentLength = 0;
|
|
73
|
+
} else {
|
|
74
|
+
res = res.slice(0, lastSlashIndex);
|
|
75
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
76
|
+
}
|
|
77
|
+
lastSlash = index;
|
|
78
|
+
dots = 0;
|
|
79
|
+
continue;
|
|
80
|
+
} else if (res.length > 0) {
|
|
81
|
+
res = "";
|
|
82
|
+
lastSegmentLength = 0;
|
|
83
|
+
lastSlash = index;
|
|
84
|
+
dots = 0;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (allowAboveRoot) {
|
|
89
|
+
res += res.length > 0 ? "/.." : "..";
|
|
90
|
+
lastSegmentLength = 2;
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
94
|
+
else res = path.slice(lastSlash + 1, index);
|
|
95
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
96
|
+
}
|
|
97
|
+
lastSlash = index;
|
|
98
|
+
dots = 0;
|
|
99
|
+
} else if (char === "." && dots !== -1) ++dots;
|
|
100
|
+
else dots = -1;
|
|
101
|
+
}
|
|
102
|
+
return res;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
exports.joinPaths = joinPaths;
|
|
@@ -1,2 +1,107 @@
|
|
|
1
|
-
import{DRIVE_LETTER_REGEX
|
|
1
|
+
import { DRIVE_LETTER_REGEX, DRIVE_LETTER_START_REGEX, UNC_REGEX } from "./regex.mjs";
|
|
2
|
+
import { isAbsolute } from "./is-type.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../path/src/join-paths.ts
|
|
5
|
+
function normalizeWindowsPath(input = "") {
|
|
6
|
+
if (!input) return input;
|
|
7
|
+
return input.replace(/\\/g, "/").replace(DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
|
|
8
|
+
}
|
|
9
|
+
function correctPaths(path) {
|
|
10
|
+
if (!path || path.length === 0) return ".";
|
|
11
|
+
path = normalizeWindowsPath(path);
|
|
12
|
+
const isUNCPath = path.match(UNC_REGEX);
|
|
13
|
+
const isPathAbsolute = isAbsolute(path);
|
|
14
|
+
const trailingSeparator = path[path.length - 1] === "/";
|
|
15
|
+
path = normalizeString(path, !isPathAbsolute);
|
|
16
|
+
if (path.length === 0) {
|
|
17
|
+
if (isPathAbsolute) return "/";
|
|
18
|
+
return trailingSeparator ? "./" : ".";
|
|
19
|
+
}
|
|
20
|
+
if (trailingSeparator) path += "/";
|
|
21
|
+
if (DRIVE_LETTER_REGEX.test(path)) path += "/";
|
|
22
|
+
if (isUNCPath) {
|
|
23
|
+
if (!isPathAbsolute) return `//./${path}`;
|
|
24
|
+
return `//${path}`;
|
|
25
|
+
}
|
|
26
|
+
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Joins all given path segments together using the platform-specific separator as a delimiter.
|
|
30
|
+
* The resulting path is normalized to remove any redundant or unnecessary segments.
|
|
31
|
+
*
|
|
32
|
+
* @param segments - The path segments to join.
|
|
33
|
+
* @returns The joined and normalized path string.
|
|
34
|
+
*/
|
|
35
|
+
function joinPaths(...segments) {
|
|
36
|
+
let path = "";
|
|
37
|
+
for (const seg of segments) {
|
|
38
|
+
if (!seg) continue;
|
|
39
|
+
if (path.length > 0) {
|
|
40
|
+
const pathTrailing = path[path.length - 1] === "/";
|
|
41
|
+
const segLeading = seg[0] === "/";
|
|
42
|
+
if (pathTrailing && segLeading) path += seg.slice(1);
|
|
43
|
+
else path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
44
|
+
} else path += seg;
|
|
45
|
+
}
|
|
46
|
+
return correctPaths(path);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
|
|
50
|
+
*
|
|
51
|
+
* @param path - The path to normalize.
|
|
52
|
+
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
|
|
53
|
+
* @returns the normalized path string.
|
|
54
|
+
*/
|
|
55
|
+
function normalizeString(path, allowAboveRoot) {
|
|
56
|
+
let res = "";
|
|
57
|
+
let lastSegmentLength = 0;
|
|
58
|
+
let lastSlash = -1;
|
|
59
|
+
let dots = 0;
|
|
60
|
+
let char = null;
|
|
61
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
62
|
+
if (index < path.length) char = path[index];
|
|
63
|
+
else if (char === "/") break;
|
|
64
|
+
else char = "/";
|
|
65
|
+
if (char === "/") {
|
|
66
|
+
if (lastSlash === index - 1 || dots === 1) {} else if (dots === 2) {
|
|
67
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
68
|
+
if (res.length > 2) {
|
|
69
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
70
|
+
if (lastSlashIndex === -1) {
|
|
71
|
+
res = "";
|
|
72
|
+
lastSegmentLength = 0;
|
|
73
|
+
} else {
|
|
74
|
+
res = res.slice(0, lastSlashIndex);
|
|
75
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
76
|
+
}
|
|
77
|
+
lastSlash = index;
|
|
78
|
+
dots = 0;
|
|
79
|
+
continue;
|
|
80
|
+
} else if (res.length > 0) {
|
|
81
|
+
res = "";
|
|
82
|
+
lastSegmentLength = 0;
|
|
83
|
+
lastSlash = index;
|
|
84
|
+
dots = 0;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (allowAboveRoot) {
|
|
89
|
+
res += res.length > 0 ? "/.." : "..";
|
|
90
|
+
lastSegmentLength = 2;
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
94
|
+
else res = path.slice(lastSlash + 1, index);
|
|
95
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
96
|
+
}
|
|
97
|
+
lastSlash = index;
|
|
98
|
+
dots = 0;
|
|
99
|
+
} else if (char === "." && dots !== -1) ++dots;
|
|
100
|
+
else dots = -1;
|
|
101
|
+
}
|
|
102
|
+
return res;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
export { joinPaths };
|
|
2
107
|
//# sourceMappingURL=join-paths.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"join-paths.mjs","names":["char: string | null"],"sources":["../../../../path/src/join-paths.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isAbsolute } from \"./is-type\";\nimport {\n DRIVE_LETTER_REGEX,\n DRIVE_LETTER_START_REGEX,\n UNC_REGEX\n} from \"./regex\";\n\n// Util to normalize windows paths to posix\nfunction normalizeWindowsPath(input = \"\") {\n if (!input) {\n return input;\n }\n return input\n .replace(/\\\\/g, \"/\")\n .replace(DRIVE_LETTER_START_REGEX, r => r.toUpperCase());\n}\n\nfunction correctPaths(path?: string) {\n if (!path || path.length === 0) {\n return \".\";\n }\n\n // Normalize windows argument\n path = normalizeWindowsPath(path);\n\n const isUNCPath = path.match(UNC_REGEX);\n const isPathAbsolute = isAbsolute(path);\n const trailingSeparator = path[path.length - 1] === \"/\";\n\n // Normalize the path\n path = normalizeString(path, !isPathAbsolute);\n\n if (path.length === 0) {\n if (isPathAbsolute) {\n return \"/\";\n }\n return trailingSeparator ? \"./\" : \".\";\n }\n if (trailingSeparator) {\n path += \"/\";\n }\n if (DRIVE_LETTER_REGEX.test(path)) {\n path += \"/\";\n }\n\n if (isUNCPath) {\n if (!isPathAbsolute) {\n return `//./${path}`;\n }\n return `//${path}`;\n }\n\n return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;\n}\n\n/**\n * Joins all given path segments together using the platform-specific separator as a delimiter.\n * The resulting path is normalized to remove any redundant or unnecessary segments.\n *\n * @param segments - The path segments to join.\n * @returns The joined and normalized path string.\n */\nexport function joinPaths(...segments: string[]): string {\n let path = \"\";\n\n for (const seg of segments) {\n if (!seg) {\n continue;\n }\n if (path.length > 0) {\n const pathTrailing = path[path.length - 1] === \"/\";\n const segLeading = seg[0] === \"/\";\n const both = pathTrailing && segLeading;\n if (both) {\n path += seg.slice(1);\n } else {\n path += pathTrailing || segLeading ? seg : `/${seg}`;\n }\n } else {\n path += seg;\n }\n }\n\n return correctPaths(path);\n}\n\nexport const join = joinPaths;\n\n/**\n * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.\n *\n * @param path - The path to normalize.\n * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.\n * @returns the normalized path string.\n */\nfunction normalizeString(path: string, allowAboveRoot: boolean) {\n let res = \"\";\n let lastSegmentLength = 0;\n let lastSlash = -1;\n let dots = 0;\n let char: string | null = null;\n for (let index = 0; index <= path.length; ++index) {\n if (index < path.length) {\n // casted because we know it exists thanks to the length check\n char = path[index] as string;\n } else if (char === \"/\") {\n break;\n } else {\n char = \"/\";\n }\n if (char === \"/\") {\n if (lastSlash === index - 1 || dots === 1) {\n // NOOP\n } else if (dots === 2) {\n if (\n res.length < 2 ||\n lastSegmentLength !== 2 ||\n res[res.length - 1] !== \".\" ||\n res[res.length - 2] !== \".\"\n ) {\n if (res.length > 2) {\n const lastSlashIndex = res.lastIndexOf(\"/\");\n if (lastSlashIndex === -1) {\n res = \"\";\n lastSegmentLength = 0;\n } else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf(\"/\");\n }\n lastSlash = index;\n dots = 0;\n continue;\n } else if (res.length > 0) {\n res = \"\";\n lastSegmentLength = 0;\n lastSlash = index;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n res += res.length > 0 ? \"/..\" : \"..\";\n lastSegmentLength = 2;\n }\n } else {\n if (res.length > 0) {\n res += `/${path.slice(lastSlash + 1, index)}`;\n } else {\n res = path.slice(lastSlash + 1, index);\n }\n lastSegmentLength = index - lastSlash - 1;\n }\n lastSlash = index;\n dots = 0;\n } else if (char === \".\" && dots !== -1) {\n ++dots;\n } else {\n dots = -1;\n }\n }\n return res;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"join-paths.mjs","names":["char: string | null"],"sources":["../../../../path/src/join-paths.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isAbsolute } from \"./is-type\";\nimport {\n DRIVE_LETTER_REGEX,\n DRIVE_LETTER_START_REGEX,\n UNC_REGEX\n} from \"./regex\";\n\n// Util to normalize windows paths to posix\nfunction normalizeWindowsPath(input = \"\") {\n if (!input) {\n return input;\n }\n return input\n .replace(/\\\\/g, \"/\")\n .replace(DRIVE_LETTER_START_REGEX, r => r.toUpperCase());\n}\n\nfunction correctPaths(path?: string) {\n if (!path || path.length === 0) {\n return \".\";\n }\n\n // Normalize windows argument\n path = normalizeWindowsPath(path);\n\n const isUNCPath = path.match(UNC_REGEX);\n const isPathAbsolute = isAbsolute(path);\n const trailingSeparator = path[path.length - 1] === \"/\";\n\n // Normalize the path\n path = normalizeString(path, !isPathAbsolute);\n\n if (path.length === 0) {\n if (isPathAbsolute) {\n return \"/\";\n }\n return trailingSeparator ? \"./\" : \".\";\n }\n if (trailingSeparator) {\n path += \"/\";\n }\n if (DRIVE_LETTER_REGEX.test(path)) {\n path += \"/\";\n }\n\n if (isUNCPath) {\n if (!isPathAbsolute) {\n return `//./${path}`;\n }\n return `//${path}`;\n }\n\n return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;\n}\n\n/**\n * Joins all given path segments together using the platform-specific separator as a delimiter.\n * The resulting path is normalized to remove any redundant or unnecessary segments.\n *\n * @param segments - The path segments to join.\n * @returns The joined and normalized path string.\n */\nexport function joinPaths(...segments: string[]): string {\n let path = \"\";\n\n for (const seg of segments) {\n if (!seg) {\n continue;\n }\n if (path.length > 0) {\n const pathTrailing = path[path.length - 1] === \"/\";\n const segLeading = seg[0] === \"/\";\n const both = pathTrailing && segLeading;\n if (both) {\n path += seg.slice(1);\n } else {\n path += pathTrailing || segLeading ? seg : `/${seg}`;\n }\n } else {\n path += seg;\n }\n }\n\n return correctPaths(path);\n}\n\nexport const join = joinPaths;\n\n/**\n * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.\n *\n * @param path - The path to normalize.\n * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.\n * @returns the normalized path string.\n */\nfunction normalizeString(path: string, allowAboveRoot: boolean) {\n let res = \"\";\n let lastSegmentLength = 0;\n let lastSlash = -1;\n let dots = 0;\n let char: string | null = null;\n for (let index = 0; index <= path.length; ++index) {\n if (index < path.length) {\n // casted because we know it exists thanks to the length check\n char = path[index] as string;\n } else if (char === \"/\") {\n break;\n } else {\n char = \"/\";\n }\n if (char === \"/\") {\n if (lastSlash === index - 1 || dots === 1) {\n // NOOP\n } else if (dots === 2) {\n if (\n res.length < 2 ||\n lastSegmentLength !== 2 ||\n res[res.length - 1] !== \".\" ||\n res[res.length - 2] !== \".\"\n ) {\n if (res.length > 2) {\n const lastSlashIndex = res.lastIndexOf(\"/\");\n if (lastSlashIndex === -1) {\n res = \"\";\n lastSegmentLength = 0;\n } else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf(\"/\");\n }\n lastSlash = index;\n dots = 0;\n continue;\n } else if (res.length > 0) {\n res = \"\";\n lastSegmentLength = 0;\n lastSlash = index;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n res += res.length > 0 ? \"/..\" : \"..\";\n lastSegmentLength = 2;\n }\n } else {\n if (res.length > 0) {\n res += `/${path.slice(lastSlash + 1, index)}`;\n } else {\n res = path.slice(lastSlash + 1, index);\n }\n lastSegmentLength = index - lastSlash - 1;\n }\n lastSlash = index;\n dots = 0;\n } else if (char === \".\" && dots !== -1) {\n ++dots;\n } else {\n dots = -1;\n }\n }\n return res;\n}\n"],"mappings":";;;;AA0BA,SAAS,qBAAqB,QAAQ,IAAI;AACxC,KAAI,CAAC,MACH,QAAO;AAET,QAAO,MACJ,QAAQ,OAAO,IAAI,CACnB,QAAQ,2BAA0B,MAAK,EAAE,aAAa,CAAC;;AAG5D,SAAS,aAAa,MAAe;AACnC,KAAI,CAAC,QAAQ,KAAK,WAAW,EAC3B,QAAO;AAIT,QAAO,qBAAqB,KAAK;CAEjC,MAAM,YAAY,KAAK,MAAM,UAAU;CACvC,MAAM,iBAAiB,WAAW,KAAK;CACvC,MAAM,oBAAoB,KAAK,KAAK,SAAS,OAAO;AAGpD,QAAO,gBAAgB,MAAM,CAAC,eAAe;AAE7C,KAAI,KAAK,WAAW,GAAG;AACrB,MAAI,eACF,QAAO;AAET,SAAO,oBAAoB,OAAO;;AAEpC,KAAI,kBACF,SAAQ;AAEV,KAAI,mBAAmB,KAAK,KAAK,CAC/B,SAAQ;AAGV,KAAI,WAAW;AACb,MAAI,CAAC,eACH,QAAO,OAAO;AAEhB,SAAO,KAAK;;AAGd,QAAO,kBAAkB,CAAC,WAAW,KAAK,GAAG,IAAI,SAAS;;;;;;;;;AAU5D,SAAgB,UAAU,GAAG,UAA4B;CACvD,IAAI,OAAO;AAEX,MAAK,MAAM,OAAO,UAAU;AAC1B,MAAI,CAAC,IACH;AAEF,MAAI,KAAK,SAAS,GAAG;GACnB,MAAM,eAAe,KAAK,KAAK,SAAS,OAAO;GAC/C,MAAM,aAAa,IAAI,OAAO;AAE9B,OADa,gBAAgB,WAE3B,SAAQ,IAAI,MAAM,EAAE;OAEpB,SAAQ,gBAAgB,aAAa,MAAM,IAAI;QAGjD,SAAQ;;AAIZ,QAAO,aAAa,KAAK;;;;;;;;;AAY3B,SAAS,gBAAgB,MAAc,gBAAyB;CAC9D,IAAI,MAAM;CACV,IAAI,oBAAoB;CACxB,IAAI,YAAY;CAChB,IAAI,OAAO;CACX,IAAIA,OAAsB;AAC1B,MAAK,IAAI,QAAQ,GAAG,SAAS,KAAK,QAAQ,EAAE,OAAO;AACjD,MAAI,QAAQ,KAAK,OAEf,QAAO,KAAK;WACH,SAAS,IAClB;MAEA,QAAO;AAET,MAAI,SAAS,KAAK;AAChB,OAAI,cAAc,QAAQ,KAAK,SAAS,GAAG,YAEhC,SAAS,GAAG;AACrB,QACE,IAAI,SAAS,KACb,sBAAsB,KACtB,IAAI,IAAI,SAAS,OAAO,OACxB,IAAI,IAAI,SAAS,OAAO,KAExB;SAAI,IAAI,SAAS,GAAG;MAClB,MAAM,iBAAiB,IAAI,YAAY,IAAI;AAC3C,UAAI,mBAAmB,IAAI;AACzB,aAAM;AACN,2BAAoB;aACf;AACL,aAAM,IAAI,MAAM,GAAG,eAAe;AAClC,2BAAoB,IAAI,SAAS,IAAI,IAAI,YAAY,IAAI;;AAE3D,kBAAY;AACZ,aAAO;AACP;gBACS,IAAI,SAAS,GAAG;AACzB,YAAM;AACN,0BAAoB;AACpB,kBAAY;AACZ,aAAO;AACP;;;AAGJ,QAAI,gBAAgB;AAClB,YAAO,IAAI,SAAS,IAAI,QAAQ;AAChC,yBAAoB;;UAEjB;AACL,QAAI,IAAI,SAAS,EACf,QAAO,IAAI,KAAK,MAAM,YAAY,GAAG,MAAM;QAE3C,OAAM,KAAK,MAAM,YAAY,GAAG,MAAM;AAExC,wBAAoB,QAAQ,YAAY;;AAE1C,eAAY;AACZ,UAAO;aACE,SAAS,OAAO,SAAS,GAClC,GAAE;MAEF,QAAO;;AAGX,QAAO"}
|
package/dist/path/src/regex.cjs
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region ../path/src/regex.ts
|
|
3
|
+
const DRIVE_LETTER_START_REGEX = /^[A-Z]:\//i;
|
|
4
|
+
const DRIVE_LETTER_REGEX = /^[A-Z]:$/i;
|
|
5
|
+
const UNC_REGEX = /^[/\\]{2}/;
|
|
6
|
+
const ABSOLUTE_PATH_REGEX = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i;
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.ABSOLUTE_PATH_REGEX = ABSOLUTE_PATH_REGEX;
|
|
10
|
+
exports.DRIVE_LETTER_REGEX = DRIVE_LETTER_REGEX;
|
|
11
|
+
exports.DRIVE_LETTER_START_REGEX = DRIVE_LETTER_START_REGEX;
|
|
12
|
+
exports.UNC_REGEX = UNC_REGEX;
|
package/dist/path/src/regex.mjs
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
//#region ../path/src/regex.ts
|
|
2
|
+
const DRIVE_LETTER_START_REGEX = /^[A-Z]:\//i;
|
|
3
|
+
const DRIVE_LETTER_REGEX = /^[A-Z]:$/i;
|
|
4
|
+
const UNC_REGEX = /^[/\\]{2}/;
|
|
5
|
+
const ABSOLUTE_PATH_REGEX = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i;
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { ABSOLUTE_PATH_REGEX, DRIVE_LETTER_REGEX, DRIVE_LETTER_START_REGEX, UNC_REGEX };
|
|
2
9
|
//# sourceMappingURL=regex.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regex.mjs","names":[],"sources":["../../../../path/src/regex.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const DRIVE_LETTER_START_REGEX = /^[A-Z]:\\//i;\nexport const DRIVE_LETTER_REGEX = /^[A-Z]:$/i;\n\nexport const UNC_REGEX = /^[/\\\\]{2}/;\n\nexport const ABSOLUTE_PATH_REGEX =\n /^[/\\\\](?![/\\\\])|^[/\\\\]{2}(?!\\.)|^~[/\\\\]|^[A-Z]:[/\\\\]/i;\n\nexport const ROOT_FOLDER_REGEX = /^\\/([A-Z]:)?$/i;\n\nexport const FILE_EXTENSION_REGEX = /\\.[0-9a-z]+$/i;\n\nexport const PACKAGE_PATH_REGEX = /^@\\w+\\/.*$/;\nexport const NPM_SCOPED_PACKAGE_REGEX = /^(?:@[\\w-]+\\/)?[\\w-]+$/;\n"],"mappings":"AAkBA,MAAa,
|
|
1
|
+
{"version":3,"file":"regex.mjs","names":[],"sources":["../../../../path/src/regex.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const DRIVE_LETTER_START_REGEX = /^[A-Z]:\\//i;\nexport const DRIVE_LETTER_REGEX = /^[A-Z]:$/i;\n\nexport const UNC_REGEX = /^[/\\\\]{2}/;\n\nexport const ABSOLUTE_PATH_REGEX =\n /^[/\\\\](?![/\\\\])|^[/\\\\]{2}(?!\\.)|^~[/\\\\]|^[A-Z]:[/\\\\]/i;\n\nexport const ROOT_FOLDER_REGEX = /^\\/([A-Z]:)?$/i;\n\nexport const FILE_EXTENSION_REGEX = /\\.[0-9a-z]+$/i;\n\nexport const PACKAGE_PATH_REGEX = /^@\\w+\\/.*$/;\nexport const NPM_SCOPED_PACKAGE_REGEX = /^(?:@[\\w-]+\\/)?[\\w-]+$/;\n"],"mappings":";AAkBA,MAAa,2BAA2B;AACxC,MAAa,qBAAqB;AAElC,MAAa,YAAY;AAEzB,MAAa,sBACX"}
|
package/dist/path/src/slash.cjs
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region ../path/src/slash.ts
|
|
3
|
+
/**
|
|
4
|
+
* Replace backslash to slash
|
|
5
|
+
*
|
|
6
|
+
* @param path - The string to replace
|
|
7
|
+
* @returns The string with replaced backslashes
|
|
8
|
+
*/
|
|
9
|
+
function slash(path) {
|
|
10
|
+
if (path.startsWith("\\\\?\\")) return path;
|
|
11
|
+
return path.replace(/\\/g, "/");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.slash = slash;
|
package/dist/path/src/slash.mjs
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
//#region ../path/src/slash.ts
|
|
2
|
+
/**
|
|
3
|
+
* Replace backslash to slash
|
|
4
|
+
*
|
|
5
|
+
* @param path - The string to replace
|
|
6
|
+
* @returns The string with replaced backslashes
|
|
7
|
+
*/
|
|
8
|
+
function slash(path) {
|
|
9
|
+
if (path.startsWith("\\\\?\\")) return path;
|
|
10
|
+
return path.replace(/\\/g, "/");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { slash };
|
|
2
15
|
//# sourceMappingURL=slash.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slash.mjs","names":[],"sources":["../../../../path/src/slash.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isAbsolutePath } from \"./is-type\";\n\n/**\n * Replace backslash to slash\n *\n * @param path - The string to replace\n * @returns The string with replaced backslashes\n */\nexport function slash(path: string) {\n if (path.startsWith(\"\\\\\\\\?\\\\\")) {\n return path;\n }\n\n return path.replace(/\\\\/g, \"/\");\n}\n\n/**\n * Replace backslash to slash and remove unneeded leading and trailing slashes\n *\n * @param path - The string to replace\n * @returns The string with replaced backslashes\n */\nexport function formatSlash(path: string) {\n const formatted = slash(path);\n\n return isAbsolutePath(formatted)\n ? formatted.replace(/\\/+$/g, \"\")\n : formatted.replace(/^\\.\\//g, \"\").replace(/\\/+$/g, \"\");\n}\n"],"mappings":"AA0BA,SAAgB,
|
|
1
|
+
{"version":3,"file":"slash.mjs","names":[],"sources":["../../../../path/src/slash.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isAbsolutePath } from \"./is-type\";\n\n/**\n * Replace backslash to slash\n *\n * @param path - The string to replace\n * @returns The string with replaced backslashes\n */\nexport function slash(path: string) {\n if (path.startsWith(\"\\\\\\\\?\\\\\")) {\n return path;\n }\n\n return path.replace(/\\\\/g, \"/\");\n}\n\n/**\n * Replace backslash to slash and remove unneeded leading and trailing slashes\n *\n * @param path - The string to replace\n * @returns The string with replaced backslashes\n */\nexport function formatSlash(path: string) {\n const formatted = slash(path);\n\n return isAbsolutePath(formatted)\n ? formatted.replace(/\\/+$/g, \"\")\n : formatted.replace(/^\\.\\//g, \"\").replace(/\\/+$/g, \"\");\n}\n"],"mappings":";;;;;;;AA0BA,SAAgB,MAAM,MAAc;AAClC,KAAI,KAAK,WAAW,UAAU,CAC5B,QAAO;AAGT,QAAO,KAAK,QAAQ,OAAO,IAAI"}
|
package/dist/providers.cjs
CHANGED
|
@@ -1 +1,112 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/providers.ts
|
|
3
|
+
const providers = [
|
|
4
|
+
["APPVEYOR"],
|
|
5
|
+
[
|
|
6
|
+
"AWS_AMPLIFY",
|
|
7
|
+
"AWS_APP_ID",
|
|
8
|
+
{ ci: true }
|
|
9
|
+
],
|
|
10
|
+
["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],
|
|
11
|
+
["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],
|
|
12
|
+
["APPCIRCLE", "AC_APPCIRCLE"],
|
|
13
|
+
["BAMBOO", "bamboo_planKey"],
|
|
14
|
+
["BITBUCKET", "BITBUCKET_COMMIT"],
|
|
15
|
+
["BITRISE", "BITRISE_IO"],
|
|
16
|
+
["BUDDY", "BUDDY_WORKSPACE_ID"],
|
|
17
|
+
["BUILDKITE"],
|
|
18
|
+
["CIRCLE", "CIRCLECI"],
|
|
19
|
+
["CIRRUS", "CIRRUS_CI"],
|
|
20
|
+
[
|
|
21
|
+
"CLOUDFLARE_PAGES",
|
|
22
|
+
"CF_PAGES",
|
|
23
|
+
{ ci: true }
|
|
24
|
+
],
|
|
25
|
+
["CODEBUILD", "CODEBUILD_BUILD_ARN"],
|
|
26
|
+
["CODEFRESH", "CF_BUILD_ID"],
|
|
27
|
+
["DRONE"],
|
|
28
|
+
["DRONE", "DRONE_BUILD_EVENT"],
|
|
29
|
+
["DSARI"],
|
|
30
|
+
["GITHUB_ACTIONS"],
|
|
31
|
+
["GITLAB", "GITLAB_CI"],
|
|
32
|
+
["GITLAB", "CI_MERGE_REQUEST_ID"],
|
|
33
|
+
["GOCD", "GO_PIPELINE_LABEL"],
|
|
34
|
+
["LAYERCI"],
|
|
35
|
+
["HUDSON", "HUDSON_URL"],
|
|
36
|
+
["JENKINS", "JENKINS_URL"],
|
|
37
|
+
["MAGNUM"],
|
|
38
|
+
["NETLIFY"],
|
|
39
|
+
[
|
|
40
|
+
"NETLIFY",
|
|
41
|
+
"NETLIFY_LOCAL",
|
|
42
|
+
{ ci: false }
|
|
43
|
+
],
|
|
44
|
+
["NEVERCODE"],
|
|
45
|
+
["RENDER"],
|
|
46
|
+
["SAIL", "SAILCI"],
|
|
47
|
+
["SEMAPHORE"],
|
|
48
|
+
["SCREWDRIVER"],
|
|
49
|
+
["SHIPPABLE"],
|
|
50
|
+
["SOLANO", "TDDIUM"],
|
|
51
|
+
["STRIDER"],
|
|
52
|
+
["TEAMCITY", "TEAMCITY_VERSION"],
|
|
53
|
+
["TRAVIS"],
|
|
54
|
+
["VERCEL", "NOW_BUILDER"],
|
|
55
|
+
[
|
|
56
|
+
"VERCEL",
|
|
57
|
+
"VERCEL",
|
|
58
|
+
{ ci: false }
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
"VERCEL",
|
|
62
|
+
"VERCEL_ENV",
|
|
63
|
+
{ ci: false }
|
|
64
|
+
],
|
|
65
|
+
["APPCENTER", "APPCENTER_BUILD_ID"],
|
|
66
|
+
[
|
|
67
|
+
"CODESANDBOX",
|
|
68
|
+
"CODESANDBOX_SSE",
|
|
69
|
+
{ ci: false }
|
|
70
|
+
],
|
|
71
|
+
["STACKBLITZ"],
|
|
72
|
+
["STORMKIT"],
|
|
73
|
+
["CLEAVR"],
|
|
74
|
+
["ZEABUR"],
|
|
75
|
+
[
|
|
76
|
+
"CODESPHERE",
|
|
77
|
+
"CODESPHERE_APP_ID",
|
|
78
|
+
{ ci: true }
|
|
79
|
+
],
|
|
80
|
+
["RAILWAY", "RAILWAY_PROJECT_ID"],
|
|
81
|
+
["RAILWAY", "RAILWAY_SERVICE_ID"],
|
|
82
|
+
["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"],
|
|
83
|
+
[
|
|
84
|
+
"FIREBASE_APP_HOSTING",
|
|
85
|
+
"FIREBASE_APP_HOSTING",
|
|
86
|
+
{ ci: true }
|
|
87
|
+
]
|
|
88
|
+
];
|
|
89
|
+
function detectProvider() {
|
|
90
|
+
if (process?.env) for (const provider$1 of providers) {
|
|
91
|
+
const envName = provider$1[1] || provider$1[0];
|
|
92
|
+
if (process?.env[envName]) return {
|
|
93
|
+
name: provider$1[0].toLowerCase(),
|
|
94
|
+
...provider$1[2]
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (process?.env?.SHELL === "/bin/jsh" && process?.versions?.webcontainer) return {
|
|
98
|
+
name: "stackblitz",
|
|
99
|
+
ci: false
|
|
100
|
+
};
|
|
101
|
+
return {
|
|
102
|
+
name: "",
|
|
103
|
+
ci: false
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** Current provider info */
|
|
107
|
+
const providerInfo = detectProvider();
|
|
108
|
+
const provider = providerInfo.name;
|
|
109
|
+
|
|
110
|
+
//#endregion
|
|
111
|
+
exports.provider = provider;
|
|
112
|
+
exports.providerInfo = providerInfo;
|