@stryke/trpc-next 0.5.88 → 0.5.90
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/action-handler.d.cts +1 -1
- package/dist/action-handler.d.mts +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/shared.cjs +2 -2
- package/dist/shared.d.cts +1 -1
- package/dist/shared.d.mts +1 -1
- package/dist/shared.mjs +1 -1
- package/dist/tanstack-query/client.cjs +2 -3
- package/dist/tanstack-query/client.d.cts +1 -1
- package/dist/tanstack-query/client.d.cts.map +1 -1
- package/dist/tanstack-query/client.d.mts +1 -1
- package/dist/tanstack-query/client.d.mts.map +1 -1
- package/dist/tanstack-query/client.mjs +1 -2
- package/dist/tanstack-query/client.mjs.map +1 -1
- package/dist/tanstack-query/server.d.cts +1 -1
- package/dist/tanstack-query/server.d.mts +1 -1
- package/package.json +10 -61
- package/dist/env/src/ci-checks.cjs +0 -13
- package/dist/env/src/ci-checks.mjs +0 -13
- package/dist/env/src/ci-checks.mjs.map +0 -1
- package/dist/env/src/environment-checks.cjs +0 -97
- package/dist/env/src/environment-checks.mjs +0 -88
- package/dist/env/src/environment-checks.mjs.map +0 -1
- package/dist/env/src/get-env-paths.cjs +0 -10
- package/dist/env/src/get-env-paths.mjs +0 -10
- package/dist/env/src/get-env-paths.mjs.map +0 -1
- package/dist/env/src/index.cjs +0 -6
- package/dist/env/src/index.mjs +0 -6
- package/dist/env/src/load-env.cjs +0 -4
- package/dist/env/src/load-env.mjs +0 -4
- package/dist/env/src/providers.cjs +0 -111
- package/dist/env/src/providers.mjs +0 -111
- package/dist/env/src/providers.mjs.map +0 -1
- package/dist/env/src/runtime-checks.cjs +0 -60
- package/dist/env/src/runtime-checks.mjs +0 -53
- package/dist/env/src/runtime-checks.mjs.map +0 -1
- package/dist/fs/src/exists.mjs +0 -2
- package/dist/fs/src/read-file.mjs +0 -2
- package/dist/path/src/is-type.cjs +0 -28
- package/dist/path/src/is-type.mjs +0 -29
- package/dist/path/src/is-type.mjs.map +0 -1
- package/dist/path/src/join-paths.cjs +0 -122
- package/dist/path/src/join-paths.mjs +0 -123
- package/dist/path/src/join-paths.mjs.map +0 -1
- package/dist/path/src/regex.cjs +0 -12
- package/dist/path/src/regex.mjs +0 -9
- package/dist/path/src/regex.mjs.map +0 -1
- package/dist/path/src/slash.cjs +0 -15
- package/dist/path/src/slash.mjs +0 -15
- package/dist/path/src/slash.mjs.map +0 -1
- package/dist/string-format/src/acronyms.cjs +0 -413
- package/dist/string-format/src/acronyms.mjs +0 -413
- package/dist/string-format/src/acronyms.mjs.map +0 -1
- package/dist/string-format/src/format-special-cases.cjs +0 -1
- package/dist/string-format/src/format-special-cases.mjs +0 -1
- package/dist/string-format/src/title-case.cjs +0 -2
- package/dist/string-format/src/title-case.mjs +0 -2
- package/dist/types/src/base.d.cts +0 -14
- package/dist/types/src/base.d.cts.map +0 -1
- package/dist/types/src/base.d.mts +0 -14
- package/dist/types/src/base.d.mts.map +0 -1
- package/dist/url/src/index.d.cts +0 -1
- package/dist/url/src/index.d.mts +0 -1
- package/dist/url/src/storm-url.d.cts +0 -1
- package/dist/url/src/storm-url.d.mts +0 -1
- package/dist/url/src/types.d.cts +0 -76
- package/dist/url/src/types.d.cts.map +0 -1
- package/dist/url/src/types.d.mts +0 -76
- package/dist/url/src/types.d.mts.map +0 -1
package/dist/env/src/index.cjs
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
const require_ci_checks = require('./ci-checks.cjs');
|
|
2
|
-
const require_environment_checks = require('./environment-checks.cjs');
|
|
3
|
-
require('./get-env-paths.cjs');
|
|
4
|
-
require('./load-env.cjs');
|
|
5
|
-
const require_providers = require('./providers.cjs');
|
|
6
|
-
const require_runtime_checks = require('./runtime-checks.cjs');
|
package/dist/env/src/index.mjs
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { isCI } from "./ci-checks.mjs";
|
|
2
|
-
import { hasTTY, isDebug, isDevelopment, isDevelopmentMode, isProductionMode, isStaging, isTest, isTestMode, isWindows, nodeVersion, platform } from "./environment-checks.mjs";
|
|
3
|
-
import "./get-env-paths.mjs";
|
|
4
|
-
import "./load-env.mjs";
|
|
5
|
-
import { providerInfo } from "./providers.mjs";
|
|
6
|
-
import { isBun, isDeno, isEdgeLight, isFastly, isNetlify, isNode, isWorkerd, runtimeInfo } from "./runtime-checks.mjs";
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../env/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 of providers) {
|
|
91
|
-
const envName = provider[1] || provider[0];
|
|
92
|
-
if (process?.env[envName]) return {
|
|
93
|
-
name: provider[0].toLowerCase(),
|
|
94
|
-
...provider[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.providerInfo = providerInfo;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
//#region ../env/src/providers.ts
|
|
2
|
-
const providers = [
|
|
3
|
-
["APPVEYOR"],
|
|
4
|
-
[
|
|
5
|
-
"AWS_AMPLIFY",
|
|
6
|
-
"AWS_APP_ID",
|
|
7
|
-
{ ci: true }
|
|
8
|
-
],
|
|
9
|
-
["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],
|
|
10
|
-
["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],
|
|
11
|
-
["APPCIRCLE", "AC_APPCIRCLE"],
|
|
12
|
-
["BAMBOO", "bamboo_planKey"],
|
|
13
|
-
["BITBUCKET", "BITBUCKET_COMMIT"],
|
|
14
|
-
["BITRISE", "BITRISE_IO"],
|
|
15
|
-
["BUDDY", "BUDDY_WORKSPACE_ID"],
|
|
16
|
-
["BUILDKITE"],
|
|
17
|
-
["CIRCLE", "CIRCLECI"],
|
|
18
|
-
["CIRRUS", "CIRRUS_CI"],
|
|
19
|
-
[
|
|
20
|
-
"CLOUDFLARE_PAGES",
|
|
21
|
-
"CF_PAGES",
|
|
22
|
-
{ ci: true }
|
|
23
|
-
],
|
|
24
|
-
["CODEBUILD", "CODEBUILD_BUILD_ARN"],
|
|
25
|
-
["CODEFRESH", "CF_BUILD_ID"],
|
|
26
|
-
["DRONE"],
|
|
27
|
-
["DRONE", "DRONE_BUILD_EVENT"],
|
|
28
|
-
["DSARI"],
|
|
29
|
-
["GITHUB_ACTIONS"],
|
|
30
|
-
["GITLAB", "GITLAB_CI"],
|
|
31
|
-
["GITLAB", "CI_MERGE_REQUEST_ID"],
|
|
32
|
-
["GOCD", "GO_PIPELINE_LABEL"],
|
|
33
|
-
["LAYERCI"],
|
|
34
|
-
["HUDSON", "HUDSON_URL"],
|
|
35
|
-
["JENKINS", "JENKINS_URL"],
|
|
36
|
-
["MAGNUM"],
|
|
37
|
-
["NETLIFY"],
|
|
38
|
-
[
|
|
39
|
-
"NETLIFY",
|
|
40
|
-
"NETLIFY_LOCAL",
|
|
41
|
-
{ ci: false }
|
|
42
|
-
],
|
|
43
|
-
["NEVERCODE"],
|
|
44
|
-
["RENDER"],
|
|
45
|
-
["SAIL", "SAILCI"],
|
|
46
|
-
["SEMAPHORE"],
|
|
47
|
-
["SCREWDRIVER"],
|
|
48
|
-
["SHIPPABLE"],
|
|
49
|
-
["SOLANO", "TDDIUM"],
|
|
50
|
-
["STRIDER"],
|
|
51
|
-
["TEAMCITY", "TEAMCITY_VERSION"],
|
|
52
|
-
["TRAVIS"],
|
|
53
|
-
["VERCEL", "NOW_BUILDER"],
|
|
54
|
-
[
|
|
55
|
-
"VERCEL",
|
|
56
|
-
"VERCEL",
|
|
57
|
-
{ ci: false }
|
|
58
|
-
],
|
|
59
|
-
[
|
|
60
|
-
"VERCEL",
|
|
61
|
-
"VERCEL_ENV",
|
|
62
|
-
{ ci: false }
|
|
63
|
-
],
|
|
64
|
-
["APPCENTER", "APPCENTER_BUILD_ID"],
|
|
65
|
-
[
|
|
66
|
-
"CODESANDBOX",
|
|
67
|
-
"CODESANDBOX_SSE",
|
|
68
|
-
{ ci: false }
|
|
69
|
-
],
|
|
70
|
-
["STACKBLITZ"],
|
|
71
|
-
["STORMKIT"],
|
|
72
|
-
["CLEAVR"],
|
|
73
|
-
["ZEABUR"],
|
|
74
|
-
[
|
|
75
|
-
"CODESPHERE",
|
|
76
|
-
"CODESPHERE_APP_ID",
|
|
77
|
-
{ ci: true }
|
|
78
|
-
],
|
|
79
|
-
["RAILWAY", "RAILWAY_PROJECT_ID"],
|
|
80
|
-
["RAILWAY", "RAILWAY_SERVICE_ID"],
|
|
81
|
-
["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"],
|
|
82
|
-
[
|
|
83
|
-
"FIREBASE_APP_HOSTING",
|
|
84
|
-
"FIREBASE_APP_HOSTING",
|
|
85
|
-
{ ci: true }
|
|
86
|
-
]
|
|
87
|
-
];
|
|
88
|
-
function detectProvider() {
|
|
89
|
-
if (process?.env) for (const provider of providers) {
|
|
90
|
-
const envName = provider[1] || provider[0];
|
|
91
|
-
if (process?.env[envName]) return {
|
|
92
|
-
name: provider[0].toLowerCase(),
|
|
93
|
-
...provider[2]
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
if (process?.env?.SHELL === "/bin/jsh" && process?.versions?.webcontainer) return {
|
|
97
|
-
name: "stackblitz",
|
|
98
|
-
ci: false
|
|
99
|
-
};
|
|
100
|
-
return {
|
|
101
|
-
name: "",
|
|
102
|
-
ci: false
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
/** Current provider info */
|
|
106
|
-
const providerInfo = detectProvider();
|
|
107
|
-
const provider = providerInfo.name;
|
|
108
|
-
|
|
109
|
-
//#endregion
|
|
110
|
-
export { providerInfo };
|
|
111
|
-
//# sourceMappingURL=providers.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"providers.mjs","names":[],"sources":["../../../../env/src/providers.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\n// Reference: https://github.com/watson/ci-info/blob/v3.2.0/vendors.json\n\nexport type ProviderName =\n | \"\"\n | \"appveyor\"\n | \"aws_amplify\"\n | \"azure_pipelines\"\n | \"azure_static\"\n | \"appcircle\"\n | \"bamboo\"\n | \"bitbucket\"\n | \"bitrise\"\n | \"buddy\"\n | \"buildkite\"\n | \"circle\"\n | \"cirrus\"\n | \"cloudflare_pages\"\n | \"codebuild\"\n | \"codefresh\"\n | \"drone\"\n | \"drone\"\n | \"dsari\"\n | \"github_actions\"\n | \"gitlab\"\n | \"gocd\"\n | \"layerci\"\n | \"hudson\"\n | \"jenkins\"\n | \"magnum\"\n | \"netlify\"\n | \"nevercode\"\n | \"render\"\n | \"sail\"\n | \"semaphore\"\n | \"screwdriver\"\n | \"shippable\"\n | \"solano\"\n | \"strider\"\n | \"teamcity\"\n | \"travis\"\n | \"vercel\"\n | \"appcenter\"\n | \"codesandbox\"\n | \"stackblitz\"\n | \"stormkit\"\n | \"cleavr\"\n | \"zeabur\"\n | \"codesphere\"\n | \"railway\"\n | \"deno-deploy\"\n | \"firebase_app_hosting\";\n\ntype InternalProvider = [\n providerName: Uppercase<ProviderName>,\n envName?: string,\n meta?: Record<string, any>\n];\n\nconst providers: InternalProvider[] = [\n [\"APPVEYOR\"],\n [\"AWS_AMPLIFY\", \"AWS_APP_ID\", { ci: true }],\n [\"AZURE_PIPELINES\", \"SYSTEM_TEAMFOUNDATIONCOLLECTIONURI\"],\n [\"AZURE_STATIC\", \"INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN\"],\n [\"APPCIRCLE\", \"AC_APPCIRCLE\"],\n [\"BAMBOO\", \"bamboo_planKey\"],\n [\"BITBUCKET\", \"BITBUCKET_COMMIT\"],\n [\"BITRISE\", \"BITRISE_IO\"],\n [\"BUDDY\", \"BUDDY_WORKSPACE_ID\"],\n [\"BUILDKITE\"],\n [\"CIRCLE\", \"CIRCLECI\"],\n [\"CIRRUS\", \"CIRRUS_CI\"],\n [\"CLOUDFLARE_PAGES\", \"CF_PAGES\", { ci: true }],\n [\"CODEBUILD\", \"CODEBUILD_BUILD_ARN\"],\n [\"CODEFRESH\", \"CF_BUILD_ID\"],\n [\"DRONE\"],\n [\"DRONE\", \"DRONE_BUILD_EVENT\"],\n [\"DSARI\"],\n [\"GITHUB_ACTIONS\"],\n [\"GITLAB\", \"GITLAB_CI\"],\n [\"GITLAB\", \"CI_MERGE_REQUEST_ID\"],\n [\"GOCD\", \"GO_PIPELINE_LABEL\"],\n [\"LAYERCI\"],\n [\"HUDSON\", \"HUDSON_URL\"],\n [\"JENKINS\", \"JENKINS_URL\"],\n [\"MAGNUM\"],\n [\"NETLIFY\"],\n [\"NETLIFY\", \"NETLIFY_LOCAL\", { ci: false }],\n [\"NEVERCODE\"],\n [\"RENDER\"],\n [\"SAIL\", \"SAILCI\"],\n [\"SEMAPHORE\"],\n [\"SCREWDRIVER\"],\n [\"SHIPPABLE\"],\n [\"SOLANO\", \"TDDIUM\"],\n [\"STRIDER\"],\n [\"TEAMCITY\", \"TEAMCITY_VERSION\"],\n [\"TRAVIS\"],\n [\"VERCEL\", \"NOW_BUILDER\"],\n [\"VERCEL\", \"VERCEL\", { ci: false }],\n [\"VERCEL\", \"VERCEL_ENV\", { ci: false }],\n [\"APPCENTER\", \"APPCENTER_BUILD_ID\"],\n [\"CODESANDBOX\", \"CODESANDBOX_SSE\", { ci: false }],\n [\"STACKBLITZ\"],\n [\"STORMKIT\"],\n [\"CLEAVR\"],\n [\"ZEABUR\"],\n [\"CODESPHERE\", \"CODESPHERE_APP_ID\", { ci: true }],\n [\"RAILWAY\", \"RAILWAY_PROJECT_ID\"],\n [\"RAILWAY\", \"RAILWAY_SERVICE_ID\"],\n [\"DENO-DEPLOY\", \"DENO_DEPLOYMENT_ID\"],\n [\"FIREBASE_APP_HOSTING\", \"FIREBASE_APP_HOSTING\", { ci: true }]\n];\n\nexport interface ProviderInfo {\n name: ProviderName;\n ci?: boolean;\n [meta: string]: any;\n}\n\nfunction detectProvider(): ProviderInfo {\n // Based on env\n if (process?.env) {\n for (const provider of providers) {\n const envName = provider[1] || provider[0];\n if (process?.env[envName]) {\n return {\n name: provider[0].toLowerCase(),\n ...(provider[2] as any)\n };\n }\n }\n }\n\n // Stackblitz / Webcontainer\n if (process?.env?.SHELL === \"/bin/jsh\" && process?.versions?.webcontainer) {\n return {\n name: \"stackblitz\",\n ci: false\n };\n }\n\n return {\n name: \"\",\n ci: false\n };\n}\n\n/** Current provider info */\nexport const providerInfo = detectProvider();\nexport const provider: ProviderName = providerInfo.name;\n"],"mappings":";AA4EA,MAAM,YAAgC;CACpC,CAAC,WAAW;CACZ;EAAC;EAAe;EAAc,EAAE,IAAI,MAAM;EAAC;CAC3C,CAAC,mBAAmB,qCAAqC;CACzD,CAAC,gBAAgB,wCAAwC;CACzD,CAAC,aAAa,eAAe;CAC7B,CAAC,UAAU,iBAAiB;CAC5B,CAAC,aAAa,mBAAmB;CACjC,CAAC,WAAW,aAAa;CACzB,CAAC,SAAS,qBAAqB;CAC/B,CAAC,YAAY;CACb,CAAC,UAAU,WAAW;CACtB,CAAC,UAAU,YAAY;CACvB;EAAC;EAAoB;EAAY,EAAE,IAAI,MAAM;EAAC;CAC9C,CAAC,aAAa,sBAAsB;CACpC,CAAC,aAAa,cAAc;CAC5B,CAAC,QAAQ;CACT,CAAC,SAAS,oBAAoB;CAC9B,CAAC,QAAQ;CACT,CAAC,iBAAiB;CAClB,CAAC,UAAU,YAAY;CACvB,CAAC,UAAU,sBAAsB;CACjC,CAAC,QAAQ,oBAAoB;CAC7B,CAAC,UAAU;CACX,CAAC,UAAU,aAAa;CACxB,CAAC,WAAW,cAAc;CAC1B,CAAC,SAAS;CACV,CAAC,UAAU;CACX;EAAC;EAAW;EAAiB,EAAE,IAAI,OAAO;EAAC;CAC3C,CAAC,YAAY;CACb,CAAC,SAAS;CACV,CAAC,QAAQ,SAAS;CAClB,CAAC,YAAY;CACb,CAAC,cAAc;CACf,CAAC,YAAY;CACb,CAAC,UAAU,SAAS;CACpB,CAAC,UAAU;CACX,CAAC,YAAY,mBAAmB;CAChC,CAAC,SAAS;CACV,CAAC,UAAU,cAAc;CACzB;EAAC;EAAU;EAAU,EAAE,IAAI,OAAO;EAAC;CACnC;EAAC;EAAU;EAAc,EAAE,IAAI,OAAO;EAAC;CACvC,CAAC,aAAa,qBAAqB;CACnC;EAAC;EAAe;EAAmB,EAAE,IAAI,OAAO;EAAC;CACjD,CAAC,aAAa;CACd,CAAC,WAAW;CACZ,CAAC,SAAS;CACV,CAAC,SAAS;CACV;EAAC;EAAc;EAAqB,EAAE,IAAI,MAAM;EAAC;CACjD,CAAC,WAAW,qBAAqB;CACjC,CAAC,WAAW,qBAAqB;CACjC,CAAC,eAAe,qBAAqB;CACrC;EAAC;EAAwB;EAAwB,EAAE,IAAI,MAAM;EAAC;CAC/D;AAQD,SAAS,iBAA+B;AAEtC,KAAI,SAAS,IACX,MAAK,MAAM,YAAY,WAAW;EAChC,MAAM,UAAU,SAAS,MAAM,SAAS;AACxC,MAAI,SAAS,IAAI,SACf,QAAO;GACL,MAAM,SAAS,GAAG,aAAa;GAC/B,GAAI,SAAS;GACd;;AAMP,KAAI,SAAS,KAAK,UAAU,cAAc,SAAS,UAAU,aAC3D,QAAO;EACL,MAAM;EACN,IAAI;EACL;AAGH,QAAO;EACL,MAAM;EACN,IAAI;EACL;;;AAIH,MAAa,eAAe,gBAAgB;AAC5C,MAAa,WAAyB,aAAa"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../env/src/runtime-checks.ts
|
|
3
|
-
/**
|
|
4
|
-
* Indicates if running in Node.js or a Node.js compatible runtime.
|
|
5
|
-
*
|
|
6
|
-
* **Note:** When running code in Bun and Deno with Node.js compatibility mode, `isNode` flag will be also `true`, indicating running in a Node.js compatible runtime.
|
|
7
|
-
*
|
|
8
|
-
* Use `runtime === "node"` if you need strict check for Node.js runtime.
|
|
9
|
-
*/
|
|
10
|
-
const isNode = process?.release?.name === "node";
|
|
11
|
-
/**
|
|
12
|
-
* Indicates if running in Bun runtime.
|
|
13
|
-
*/
|
|
14
|
-
const isBun = Boolean(Bun) || Boolean(process?.versions?.bun);
|
|
15
|
-
/**
|
|
16
|
-
* Indicates if running in Deno runtime.
|
|
17
|
-
*/
|
|
18
|
-
const isDeno = Boolean(Deno);
|
|
19
|
-
/**
|
|
20
|
-
* Indicates if running in Fastly runtime.
|
|
21
|
-
*/
|
|
22
|
-
const isFastly = Boolean(fastly);
|
|
23
|
-
/**
|
|
24
|
-
* Indicates if running in Netlify runtime.
|
|
25
|
-
*/
|
|
26
|
-
const isNetlify = Boolean(Netlify);
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
* Indicates if running in EdgeLight (Vercel Edge) runtime.
|
|
30
|
-
*/
|
|
31
|
-
const isEdgeLight = Boolean(EdgeRuntime);
|
|
32
|
-
/**
|
|
33
|
-
* Indicates if running in Cloudflare Workers runtime.
|
|
34
|
-
*/
|
|
35
|
-
const isWorkerd = navigator?.userAgent === "Cloudflare-Workers";
|
|
36
|
-
const runtimeChecks = [
|
|
37
|
-
[isNetlify, "netlify"],
|
|
38
|
-
[isEdgeLight, "edge-light"],
|
|
39
|
-
[isWorkerd, "workerd"],
|
|
40
|
-
[isFastly, "fastly"],
|
|
41
|
-
[isDeno, "deno"],
|
|
42
|
-
[isBun, "bun"],
|
|
43
|
-
[isNode, "node"]
|
|
44
|
-
];
|
|
45
|
-
function detectRuntime() {
|
|
46
|
-
const detectedRuntime = runtimeChecks.find((check) => check[0]);
|
|
47
|
-
if (detectedRuntime) return { name: detectedRuntime[1] };
|
|
48
|
-
}
|
|
49
|
-
const runtimeInfo = detectRuntime();
|
|
50
|
-
const runtime = runtimeInfo?.name || "";
|
|
51
|
-
|
|
52
|
-
//#endregion
|
|
53
|
-
exports.isBun = isBun;
|
|
54
|
-
exports.isDeno = isDeno;
|
|
55
|
-
exports.isEdgeLight = isEdgeLight;
|
|
56
|
-
exports.isFastly = isFastly;
|
|
57
|
-
exports.isNetlify = isNetlify;
|
|
58
|
-
exports.isNode = isNode;
|
|
59
|
-
exports.isWorkerd = isWorkerd;
|
|
60
|
-
exports.runtimeInfo = runtimeInfo;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
//#region ../env/src/runtime-checks.ts
|
|
2
|
-
/**
|
|
3
|
-
* Indicates if running in Node.js or a Node.js compatible runtime.
|
|
4
|
-
*
|
|
5
|
-
* **Note:** When running code in Bun and Deno with Node.js compatibility mode, `isNode` flag will be also `true`, indicating running in a Node.js compatible runtime.
|
|
6
|
-
*
|
|
7
|
-
* Use `runtime === "node"` if you need strict check for Node.js runtime.
|
|
8
|
-
*/
|
|
9
|
-
const isNode = process?.release?.name === "node";
|
|
10
|
-
/**
|
|
11
|
-
* Indicates if running in Bun runtime.
|
|
12
|
-
*/
|
|
13
|
-
const isBun = Boolean(Bun) || Boolean(process?.versions?.bun);
|
|
14
|
-
/**
|
|
15
|
-
* Indicates if running in Deno runtime.
|
|
16
|
-
*/
|
|
17
|
-
const isDeno = Boolean(Deno);
|
|
18
|
-
/**
|
|
19
|
-
* Indicates if running in Fastly runtime.
|
|
20
|
-
*/
|
|
21
|
-
const isFastly = Boolean(fastly);
|
|
22
|
-
/**
|
|
23
|
-
* Indicates if running in Netlify runtime.
|
|
24
|
-
*/
|
|
25
|
-
const isNetlify = Boolean(Netlify);
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* Indicates if running in EdgeLight (Vercel Edge) runtime.
|
|
29
|
-
*/
|
|
30
|
-
const isEdgeLight = Boolean(EdgeRuntime);
|
|
31
|
-
/**
|
|
32
|
-
* Indicates if running in Cloudflare Workers runtime.
|
|
33
|
-
*/
|
|
34
|
-
const isWorkerd = navigator?.userAgent === "Cloudflare-Workers";
|
|
35
|
-
const runtimeChecks = [
|
|
36
|
-
[isNetlify, "netlify"],
|
|
37
|
-
[isEdgeLight, "edge-light"],
|
|
38
|
-
[isWorkerd, "workerd"],
|
|
39
|
-
[isFastly, "fastly"],
|
|
40
|
-
[isDeno, "deno"],
|
|
41
|
-
[isBun, "bun"],
|
|
42
|
-
[isNode, "node"]
|
|
43
|
-
];
|
|
44
|
-
function detectRuntime() {
|
|
45
|
-
const detectedRuntime = runtimeChecks.find((check) => check[0]);
|
|
46
|
-
if (detectedRuntime) return { name: detectedRuntime[1] };
|
|
47
|
-
}
|
|
48
|
-
const runtimeInfo = detectRuntime();
|
|
49
|
-
const runtime = runtimeInfo?.name || "";
|
|
50
|
-
|
|
51
|
-
//#endregion
|
|
52
|
-
export { isBun, isDeno, isEdgeLight, isFastly, isNetlify, isNode, isWorkerd, runtimeInfo };
|
|
53
|
-
//# sourceMappingURL=runtime-checks.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-checks.mjs","names":[],"sources":["../../../../env/src/runtime-checks.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\n// https://runtime-keys.proposal.wintercg.org/\nexport type RuntimeName =\n | \"workerd\"\n | \"deno\"\n | \"netlify\"\n | \"node\"\n | \"bun\"\n | \"edge-light\"\n | \"fastly\"\n | \"\";\n\nexport interface RuntimeInfo {\n name: RuntimeName;\n}\n\n/**\n * Indicates if running in Node.js or a Node.js compatible runtime.\n *\n * **Note:** When running code in Bun and Deno with Node.js compatibility mode, `isNode` flag will be also `true`, indicating running in a Node.js compatible runtime.\n *\n * Use `runtime === \"node\"` if you need strict check for Node.js runtime.\n */\nexport const isNode = process?.release?.name === \"node\";\n\n/**\n * Indicates if running in Bun runtime.\n */\nexport const isBun = Boolean(Bun) || Boolean(process?.versions?.bun);\n\n/**\n * Indicates if running in Deno runtime.\n */\nexport const isDeno = Boolean(Deno);\n\n/**\n * Indicates if running in Fastly runtime.\n */\nexport const isFastly = Boolean(fastly);\n\n/**\n * Indicates if running in Netlify runtime.\n */\nexport const isNetlify = Boolean(Netlify);\n\n/**\n *\n * Indicates if running in EdgeLight (Vercel Edge) runtime.\n */\nexport const isEdgeLight = Boolean(EdgeRuntime);\n// https://developers.cloudflare.com/workers/runtime-apis/web-standards/#navigatoruseragent\n\n/**\n * Indicates if running in Cloudflare Workers runtime.\n */\nexport const isWorkerd = navigator?.userAgent === \"Cloudflare-Workers\";\n\n/**\n * Indicates if the code is running on the server-side\n */\nexport const isRuntimeServer =\n isNode ||\n isBun ||\n isDeno ||\n isFastly ||\n isNetlify ||\n isEdgeLight ||\n isWorkerd;\n\n/**\n * Indicates if the code is running in the browser (and not on the server).\n */\nexport const isRuntimeClient = !isRuntimeServer;\n\nconst runtimeChecks: [boolean, RuntimeName][] = [\n [isNetlify, \"netlify\"],\n [isEdgeLight, \"edge-light\"],\n [isWorkerd, \"workerd\"],\n [isFastly, \"fastly\"],\n [isDeno, \"deno\"],\n [isBun, \"bun\"],\n [isNode, \"node\"]\n];\n\nfunction detectRuntime(): RuntimeInfo | undefined {\n const detectedRuntime = runtimeChecks.find(check => check[0]);\n\n if (detectedRuntime) {\n const name = detectedRuntime[1];\n\n return { name };\n }\n\n return undefined;\n}\n\nexport const runtimeInfo = detectRuntime();\n\nexport const runtime: RuntimeName = runtimeInfo?.name || \"\";\n"],"mappings":";;;;;;;;AAwCA,MAAa,SAAS,SAAS,SAAS,SAAS;;;;AAKjD,MAAa,QAAQ,QAAQ,IAAI,IAAI,QAAQ,SAAS,UAAU,IAAI;;;;AAKpE,MAAa,SAAS,QAAQ,KAAK;;;;AAKnC,MAAa,WAAW,QAAQ,OAAO;;;;AAKvC,MAAa,YAAY,QAAQ,QAAQ;;;;;AAMzC,MAAa,cAAc,QAAQ,YAAY;;;;AAM/C,MAAa,YAAY,WAAW,cAAc;AAmBlD,MAAM,gBAA0C;CAC9C,CAAC,WAAW,UAAU;CACtB,CAAC,aAAa,aAAa;CAC3B,CAAC,WAAW,UAAU;CACtB,CAAC,UAAU,SAAS;CACpB,CAAC,QAAQ,OAAO;CAChB,CAAC,OAAO,MAAM;CACd,CAAC,QAAQ,OAAO;CACjB;AAED,SAAS,gBAAyC;CAChD,MAAM,kBAAkB,cAAc,MAAK,UAAS,MAAM,GAAG;AAE7D,KAAI,gBAGF,QAAO,EAAE,MAFI,gBAAgB,IAEd;;AAMnB,MAAa,cAAc,eAAe;AAE1C,MAAa,UAAuB,aAAa,QAAQ"}
|
package/dist/fs/src/exists.mjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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,29 +0,0 @@
|
|
|
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 };
|
|
29
|
-
//# sourceMappingURL=is-type.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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,122 +0,0 @@
|
|
|
1
|
-
const require_regex = require('./regex.cjs');
|
|
2
|
-
const require_slash = require('./slash.cjs');
|
|
3
|
-
const require_is_type = require('./is-type.cjs');
|
|
4
|
-
|
|
5
|
-
//#region ../path/src/join-paths.ts
|
|
6
|
-
function normalizeWindowsPath(input = "") {
|
|
7
|
-
if (!input) return input;
|
|
8
|
-
return input.replace(/\\/g, "/").replace(require_regex.DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
|
|
9
|
-
}
|
|
10
|
-
function correctPaths(path) {
|
|
11
|
-
if (!path || path.length === 0) return ".";
|
|
12
|
-
path = normalizeWindowsPath(path);
|
|
13
|
-
const isUNCPath = path.match(require_regex.UNC_REGEX);
|
|
14
|
-
const isPathAbsolute = require_is_type.isAbsolute(path);
|
|
15
|
-
const trailingSeparator = path[path.length - 1] === "/";
|
|
16
|
-
path = normalizeString(path, !isPathAbsolute);
|
|
17
|
-
if (path.length === 0) {
|
|
18
|
-
if (isPathAbsolute) return "/";
|
|
19
|
-
return trailingSeparator ? "./" : ".";
|
|
20
|
-
}
|
|
21
|
-
if (trailingSeparator) path += "/";
|
|
22
|
-
if (require_regex.DRIVE_LETTER_REGEX.test(path)) path += "/";
|
|
23
|
-
if (isUNCPath) {
|
|
24
|
-
if (!isPathAbsolute) return `//./${path}`;
|
|
25
|
-
return `//${path}`;
|
|
26
|
-
}
|
|
27
|
-
return isPathAbsolute && !require_is_type.isAbsolute(path) ? `/${path}` : path;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Joins all given path segments together using the platform-specific separator as a delimiter.
|
|
31
|
-
*
|
|
32
|
-
* @remarks
|
|
33
|
-
* Multiple segments can be provided as separate arguments. The resulting path is normalized to remove any redundant or unnecessary segments.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```ts
|
|
37
|
-
* import { joinPaths } from 'stryke/path';
|
|
38
|
-
*
|
|
39
|
-
* const fullPath = joinPaths('folder1', 'folder2', '..', 'folder3', 'file.txt');
|
|
40
|
-
* console.log(fullPath); // Output: 'folder1/folder3/file.txt'
|
|
41
|
-
*
|
|
42
|
-
* const absolutePath = joinPaths('/root', 'folder', '.', 'subfolder', 'file.txt');
|
|
43
|
-
* console.log(absolutePath); // Output: '/root/folder/subfolder/file.txt'
|
|
44
|
-
*
|
|
45
|
-
* const windowsPath = joinPaths('C:\\', 'Users', 'Public', '..', 'Documents', 'file.txt');
|
|
46
|
-
* console.log(windowsPath); // Output: 'C:/Users/Documents/file.txt'
|
|
47
|
-
*
|
|
48
|
-
* const uncPath = joinPaths('\\\\Server\\Share', 'Folder', 'File.txt');
|
|
49
|
-
* console.log(uncPath); // Output: '//Server/Share/Folder/File.txt'
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
* @param segments - The path segments to join.
|
|
53
|
-
* @returns The joined and normalized path string.
|
|
54
|
-
*/
|
|
55
|
-
function joinPaths(...segments) {
|
|
56
|
-
let result = "";
|
|
57
|
-
for (const segment of segments) if (segment && require_slash.slash(segment).replaceAll(/\//g, "") !== ".") {
|
|
58
|
-
if (result) if (require_slash.slash(segment).replaceAll(/\//g, "") === "..") result = require_slash.slash(result).replace(/\/+$/, "").replace(/\/*[^/]+$/, "");
|
|
59
|
-
else result = `${require_slash.slash(result).replace(/\/+$/, "")}/${require_slash.slash(segment).replace(/^\/+/, "")}`;
|
|
60
|
-
else if (require_slash.slash(segment).replaceAll(/\//g, "") !== "..") result = segment;
|
|
61
|
-
}
|
|
62
|
-
return correctPaths(result);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
|
|
66
|
-
*
|
|
67
|
-
* @param path - The path to normalize.
|
|
68
|
-
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
|
|
69
|
-
* @returns the normalized path string.
|
|
70
|
-
*/
|
|
71
|
-
function normalizeString(path, allowAboveRoot) {
|
|
72
|
-
let res = "";
|
|
73
|
-
let lastSegmentLength = 0;
|
|
74
|
-
let lastSlash = -1;
|
|
75
|
-
let dots = 0;
|
|
76
|
-
let char = null;
|
|
77
|
-
for (let index = 0; index <= path.length; ++index) {
|
|
78
|
-
if (index < path.length) char = path[index];
|
|
79
|
-
else if (char === "/") break;
|
|
80
|
-
else char = "/";
|
|
81
|
-
if (char === "/") {
|
|
82
|
-
if (lastSlash === index - 1 || dots === 1) {} else if (dots === 2) {
|
|
83
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
84
|
-
if (res.length > 2) {
|
|
85
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
86
|
-
if (lastSlashIndex === -1) {
|
|
87
|
-
res = "";
|
|
88
|
-
lastSegmentLength = 0;
|
|
89
|
-
} else {
|
|
90
|
-
res = res.slice(0, lastSlashIndex);
|
|
91
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
92
|
-
}
|
|
93
|
-
lastSlash = index;
|
|
94
|
-
dots = 0;
|
|
95
|
-
continue;
|
|
96
|
-
} else if (res.length > 0) {
|
|
97
|
-
res = "";
|
|
98
|
-
lastSegmentLength = 0;
|
|
99
|
-
lastSlash = index;
|
|
100
|
-
dots = 0;
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (allowAboveRoot) {
|
|
105
|
-
res += res.length > 0 ? "/.." : "..";
|
|
106
|
-
lastSegmentLength = 2;
|
|
107
|
-
}
|
|
108
|
-
} else {
|
|
109
|
-
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
110
|
-
else res = path.slice(lastSlash + 1, index);
|
|
111
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
112
|
-
}
|
|
113
|
-
lastSlash = index;
|
|
114
|
-
dots = 0;
|
|
115
|
-
} else if (char === "." && dots !== -1) ++dots;
|
|
116
|
-
else dots = -1;
|
|
117
|
-
}
|
|
118
|
-
return res;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
//#endregion
|
|
122
|
-
exports.joinPaths = joinPaths;
|