@stacksjs/utils 0.57.3 → 0.58.19
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/dist/index.js +1276 -0
- package/package.json +66 -57
- package/LICENSE.md +0 -21
- package/dist/base.d.ts +0 -3
- package/dist/base.mjs +0 -12
- package/dist/config.d.ts +0 -28
- package/dist/config.mjs +0 -79
- package/dist/currency.d.ts +0 -3
- package/dist/currency.mjs +0 -28
- package/dist/debounce.d.ts +0 -1
- package/dist/debounce.mjs +0 -1
- package/dist/delete.d.ts +0 -1
- package/dist/delete.mjs +0 -1
- package/dist/equal.d.ts +0 -1
- package/dist/equal.mjs +0 -23
- package/dist/function.d.ts +0 -18
- package/dist/function.mjs +0 -7
- package/dist/guards.d.ts +0 -28
- package/dist/guards.mjs +0 -12
- package/dist/helpers.d.ts +0 -46
- package/dist/helpers.mjs +0 -92
- package/dist/index.d.ts +0 -15
- package/dist/index.mjs +0 -15
- package/dist/math.d.ts +0 -3
- package/dist/math.mjs +0 -28
- package/dist/p.d.ts +0 -41
- package/dist/p.mjs +0 -74
- package/dist/promise.d.ts +0 -65
- package/dist/promise.mjs +0 -57
- package/dist/throttle.d.ts +0 -19
- package/dist/throttle.mjs +0 -20
- package/dist/vendors.d.ts +0 -3
- package/dist/vendors.mjs +0 -210
- package/dist/versions.d.ts +0 -1
- package/dist/versions.mjs +0 -1
package/package.json
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"packageManager": "pnpm@8.6.6",
|
|
4
|
+
"version": "0.58.19",
|
|
6
5
|
"description": "The Stacks helper functions.",
|
|
7
6
|
"author": "Chris Breuer",
|
|
8
7
|
"license": "MIT",
|
|
9
8
|
"funding": "https://github.com/sponsors/chrisbbreuer",
|
|
10
|
-
"homepage": "https://github.com/stacksjs/stacks/tree/main
|
|
9
|
+
"homepage": "https://github.com/stacksjs/stacks/tree/main/storage/framework/core/src/helpers#readme",
|
|
11
10
|
"repository": {
|
|
12
11
|
"type": "git",
|
|
13
12
|
"url": "git+https://github.com/stacksjs/stacks.git",
|
|
14
|
-
"directory": "
|
|
13
|
+
"directory": "./storage/framework/core/src/helpers"
|
|
15
14
|
},
|
|
16
15
|
"bugs": {
|
|
17
16
|
"url": "https://github.com/stacksjs/stacks/issues"
|
|
@@ -22,80 +21,90 @@
|
|
|
22
21
|
"arrays",
|
|
23
22
|
"alias",
|
|
24
23
|
"helpers",
|
|
24
|
+
"magic-regexp",
|
|
25
25
|
"utilities",
|
|
26
26
|
"functions",
|
|
27
27
|
"stacks"
|
|
28
28
|
],
|
|
29
29
|
"exports": {
|
|
30
30
|
".": {
|
|
31
|
-
"
|
|
32
|
-
"import": "./dist/index.
|
|
31
|
+
"bun": "./src/index.ts",
|
|
32
|
+
"import": "./dist/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./*": {
|
|
35
|
+
"bun": "./*"
|
|
33
36
|
}
|
|
34
37
|
},
|
|
35
|
-
"module": "dist/index.
|
|
38
|
+
"module": "dist/index.js",
|
|
36
39
|
"types": "dist/index.d.ts",
|
|
37
40
|
"contributors": [
|
|
38
|
-
"Chris Breuer <chris@
|
|
41
|
+
"Chris Breuer <chris@stacksjs.org>"
|
|
39
42
|
],
|
|
40
43
|
"files": [
|
|
41
|
-
"
|
|
42
|
-
"
|
|
44
|
+
"README.md",
|
|
45
|
+
"dist"
|
|
43
46
|
],
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "bun --bun build.ts",
|
|
49
|
+
"typecheck": "bun --bun tsc --noEmit",
|
|
50
|
+
"prepublishOnly": "bun --bun run build",
|
|
51
|
+
"size": "tsx scripts/export-size.ts"
|
|
52
|
+
},
|
|
44
53
|
"peerDependencies": {
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"@
|
|
59
|
-
"@
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"@stacksjs/storage": "0.57.3",
|
|
65
|
-
"@stacksjs/strings": "0.57.3",
|
|
66
|
-
"@stacksjs/types": "0.57.3"
|
|
54
|
+
"@stacksjs/actions": "workspace:*",
|
|
55
|
+
"@stacksjs/arrays": "workspace:*",
|
|
56
|
+
"@stacksjs/cli": "workspace:*",
|
|
57
|
+
"@stacksjs/config": "workspace:*",
|
|
58
|
+
"@stacksjs/development": "workspace:*",
|
|
59
|
+
"@stacksjs/lint": "workspace:*",
|
|
60
|
+
"@stacksjs/path": "workspace:*",
|
|
61
|
+
"@stacksjs/storage": "workspace:*",
|
|
62
|
+
"@stacksjs/strings": "workspace:*",
|
|
63
|
+
"@stacksjs/types": "workspace:*",
|
|
64
|
+
"@types/js-yaml": "^4.0.9",
|
|
65
|
+
"@vueuse/core": "^10.7.1",
|
|
66
|
+
"@vueuse/head": "^2.0.0",
|
|
67
|
+
"@vueuse/math": "^10.7.1",
|
|
68
|
+
"@vueuse/shared": "^10.7.1",
|
|
69
|
+
"export-size": "^0.7.0",
|
|
70
|
+
"js-yaml": "^4.1.0",
|
|
71
|
+
"rimraf": "^5.0.5",
|
|
72
|
+
"yaml": "^2.3.4"
|
|
67
73
|
},
|
|
68
74
|
"dependencies": {
|
|
69
75
|
"@dinero.js/currencies": "2.0.0-alpha.14",
|
|
70
|
-
"@
|
|
71
|
-
"@
|
|
72
|
-
"@
|
|
73
|
-
"@
|
|
74
|
-
"
|
|
76
|
+
"@stacksjs/actions": "workspace:*",
|
|
77
|
+
"@stacksjs/arrays": "workspace:*",
|
|
78
|
+
"@stacksjs/cli": "workspace:*",
|
|
79
|
+
"@stacksjs/config": "workspace:*",
|
|
80
|
+
"@stacksjs/lint": "workspace:*",
|
|
81
|
+
"@stacksjs/path": "workspace:*",
|
|
82
|
+
"@stacksjs/storage": "workspace:*",
|
|
83
|
+
"@stacksjs/strings": "workspace:*",
|
|
84
|
+
"@stacksjs/types": "workspace:*",
|
|
85
|
+
"@vueuse/core": "^10.7.1",
|
|
86
|
+
"@vueuse/head": "^2.0.0",
|
|
87
|
+
"@vueuse/math": "^10.7.1",
|
|
88
|
+
"@vueuse/shared": "^10.7.1",
|
|
89
|
+
"defu": "^6.1.4",
|
|
75
90
|
"detect-indent": "^7.0.1",
|
|
76
|
-
"detect-newline": "^4.0.
|
|
91
|
+
"detect-newline": "^4.0.1",
|
|
77
92
|
"dinero.js": "2.0.0-alpha.14",
|
|
78
|
-
"
|
|
93
|
+
"export-size": "^0.7.0",
|
|
94
|
+
"js-yaml": "^4.1.0",
|
|
79
95
|
"kolorist": "1.8.0",
|
|
80
|
-
"
|
|
96
|
+
"macroable": "^7.0.2",
|
|
97
|
+
"magic-regexp": "^0.7.0",
|
|
98
|
+
"p-limit": "^5.0.0",
|
|
81
99
|
"perfect-debounce": "^1.0.0",
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"yaml": "^2.3.
|
|
85
|
-
"@stacksjs/arrays": "0.57.3",
|
|
86
|
-
"@stacksjs/cli": "0.57.3",
|
|
87
|
-
"@stacksjs/config": "0.57.3",
|
|
88
|
-
"@stacksjs/lint": "0.57.3",
|
|
89
|
-
"@stacksjs/path": "0.57.3",
|
|
90
|
-
"@stacksjs/storage": "0.57.3",
|
|
91
|
-
"@stacksjs/types": "0.57.3"
|
|
100
|
+
"pretty-bytes": "^6.1.1",
|
|
101
|
+
"rimraf": "^5.0.5",
|
|
102
|
+
"yaml": "^2.3.4"
|
|
92
103
|
},
|
|
93
104
|
"devDependencies": {
|
|
94
|
-
"@stacksjs/development": "
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"
|
|
98
|
-
"dev": "unbuild --stub",
|
|
99
|
-
"typecheck": "tsc --noEmit"
|
|
105
|
+
"@stacksjs/development": "workspace:*",
|
|
106
|
+
"@types/js-yaml": "^4.0.9",
|
|
107
|
+
"markdown-table": "^3.0.3",
|
|
108
|
+
"vue-starport": "^0.4.0"
|
|
100
109
|
}
|
|
101
|
-
}
|
|
110
|
+
}
|
package/LICENSE.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Open Web Foundation
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/dist/base.d.ts
DELETED
package/dist/base.mjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function toString(v) {
|
|
2
|
-
return Object.prototype.toString.call(v);
|
|
3
|
-
}
|
|
4
|
-
export function loop(times, callback) {
|
|
5
|
-
[...Array(times)].forEach((item, i) => callback(i));
|
|
6
|
-
}
|
|
7
|
-
export function getTypeName(v) {
|
|
8
|
-
if (v === null)
|
|
9
|
-
return "null";
|
|
10
|
-
const type = toString(v).slice(8, -1).toLowerCase();
|
|
11
|
-
return typeof v === "object" || typeof v === "function" ? type : typeof v;
|
|
12
|
-
}
|
package/dist/config.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { AppOptions, CacheOptions, CdnOptions, CronJobOptions, DatabaseOptions, DebugOptions, DnsOptions, EmailOptions, Events, GitOptions, HashingOptions, JobOptions, LibraryOptions, Model, NotificationOptions, PagesOption, PaymentOptions, QueueOptions, SearchEngineOptions, ServicesOptions, StorageOptions, UiOptions, UserCliOptions } from '@stacksjs/types';
|
|
2
|
-
export { loadStacksConfig as config } from '@stacksjs/config';
|
|
3
|
-
export declare function defineApp(config: Partial<AppOptions>): AppOptions;
|
|
4
|
-
export declare function defineCache(config: Partial<CacheOptions>): CacheOptions;
|
|
5
|
-
export declare function defineCdn(config: Partial<CdnOptions>): CdnOptions;
|
|
6
|
-
export declare function defineCli(config: Partial<UserCliOptions>): UserCliOptions;
|
|
7
|
-
export declare function defineCronJobsConfig(config: Partial<CronJobOptions>[]): CronJobOptions[];
|
|
8
|
-
export declare function defineJobsConfig(config: Partial<JobOptions>[]): JobOptions[];
|
|
9
|
-
export declare function defineDatabase(config: Partial<DatabaseOptions>): DatabaseOptions;
|
|
10
|
-
export declare function defineDebugConfig(config: Partial<DebugOptions>): DebugOptions;
|
|
11
|
-
export declare function defineDns(config: Partial<DnsOptions>): DnsOptions;
|
|
12
|
-
export declare function defineEmailConfig(config: Partial<EmailOptions>): EmailOptions;
|
|
13
|
-
export declare function defineEvents(config: Partial<Events>): Events;
|
|
14
|
-
export declare function defineGit(config: Partial<GitOptions>): GitOptions;
|
|
15
|
-
export declare function defineHashing(config: Partial<HashingOptions>): HashingOptions;
|
|
16
|
-
export declare function defineLibrary(config: Partial<LibraryOptions>): LibraryOptions;
|
|
17
|
-
export declare function defineModel(config: Partial<Model>): Model;
|
|
18
|
-
export declare function defineNotification(config: Partial<NotificationOptions>): NotificationOptions;
|
|
19
|
-
export declare function defineSms(config: Partial<NotificationOptions['sms']>): NotificationOptions;
|
|
20
|
-
export declare function defineEmail(config: Partial<NotificationOptions['email']>): NotificationOptions;
|
|
21
|
-
export declare function defineChat(config: Partial<NotificationOptions['chat']>): NotificationOptions;
|
|
22
|
-
export declare function definePage(config: Partial<PagesOption>): PagesOption;
|
|
23
|
-
export declare function definePayment(config: Partial<PaymentOptions>): PaymentOptions;
|
|
24
|
-
export declare function defineQueue(config: Partial<QueueOptions>): QueueOptions;
|
|
25
|
-
export declare function defineSearchEngine(config: Partial<SearchEngineOptions>): SearchEngineOptions;
|
|
26
|
-
export declare function defineServices(config: Partial<ServicesOptions>): ServicesOptions;
|
|
27
|
-
export declare function defineStorage(config: Partial<StorageOptions>): StorageOptions;
|
|
28
|
-
export declare function defineUi(config: Partial<UiOptions>): UiOptions;
|
package/dist/config.mjs
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
export { loadStacksConfig as config } from "@stacksjs/config";
|
|
2
|
-
export function defineApp(config) {
|
|
3
|
-
return config;
|
|
4
|
-
}
|
|
5
|
-
export function defineCache(config) {
|
|
6
|
-
return config;
|
|
7
|
-
}
|
|
8
|
-
export function defineCdn(config) {
|
|
9
|
-
return config;
|
|
10
|
-
}
|
|
11
|
-
export function defineCli(config) {
|
|
12
|
-
return config;
|
|
13
|
-
}
|
|
14
|
-
export function defineCronJobsConfig(config) {
|
|
15
|
-
return config;
|
|
16
|
-
}
|
|
17
|
-
export function defineJobsConfig(config) {
|
|
18
|
-
return config;
|
|
19
|
-
}
|
|
20
|
-
export function defineDatabase(config) {
|
|
21
|
-
return config;
|
|
22
|
-
}
|
|
23
|
-
export function defineDebugConfig(config) {
|
|
24
|
-
return config;
|
|
25
|
-
}
|
|
26
|
-
export function defineDns(config) {
|
|
27
|
-
return config;
|
|
28
|
-
}
|
|
29
|
-
export function defineEmailConfig(config) {
|
|
30
|
-
return config;
|
|
31
|
-
}
|
|
32
|
-
export function defineEvents(config) {
|
|
33
|
-
return config;
|
|
34
|
-
}
|
|
35
|
-
export function defineGit(config) {
|
|
36
|
-
return config;
|
|
37
|
-
}
|
|
38
|
-
export function defineHashing(config) {
|
|
39
|
-
return config;
|
|
40
|
-
}
|
|
41
|
-
export function defineLibrary(config) {
|
|
42
|
-
return config;
|
|
43
|
-
}
|
|
44
|
-
export function defineModel(config) {
|
|
45
|
-
return config;
|
|
46
|
-
}
|
|
47
|
-
export function defineNotification(config) {
|
|
48
|
-
return config;
|
|
49
|
-
}
|
|
50
|
-
export function defineSms(config) {
|
|
51
|
-
return config;
|
|
52
|
-
}
|
|
53
|
-
export function defineEmail(config) {
|
|
54
|
-
return config;
|
|
55
|
-
}
|
|
56
|
-
export function defineChat(config) {
|
|
57
|
-
return config;
|
|
58
|
-
}
|
|
59
|
-
export function definePage(config) {
|
|
60
|
-
return config;
|
|
61
|
-
}
|
|
62
|
-
export function definePayment(config) {
|
|
63
|
-
return config;
|
|
64
|
-
}
|
|
65
|
-
export function defineQueue(config) {
|
|
66
|
-
return config;
|
|
67
|
-
}
|
|
68
|
-
export function defineSearchEngine(config) {
|
|
69
|
-
return config;
|
|
70
|
-
}
|
|
71
|
-
export function defineServices(config) {
|
|
72
|
-
return config;
|
|
73
|
-
}
|
|
74
|
-
export function defineStorage(config) {
|
|
75
|
-
return config;
|
|
76
|
-
}
|
|
77
|
-
export function defineUi(config) {
|
|
78
|
-
return config;
|
|
79
|
-
}
|
package/dist/currency.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { add, allocate, compare, convert, equal, greaterThan, greaterThanOrEqual, hasSubUnits, isZero, lessThan, lessThanOrEqual, maximum, minimum, multiply, normalizeScale, dinero, dinero as money, subtract, toSnapshot, toUnits, toDecimal, trimScale, haveSameCurrency, haveSameAmount, dinero as currency, } from 'dinero.js';
|
|
2
|
-
export { USD } from '@dinero.js/currencies';
|
|
3
|
-
export type { Dinero, Currency } from 'dinero.js';
|
package/dist/currency.mjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
add,
|
|
3
|
-
allocate,
|
|
4
|
-
compare,
|
|
5
|
-
convert,
|
|
6
|
-
equal,
|
|
7
|
-
greaterThan,
|
|
8
|
-
greaterThanOrEqual,
|
|
9
|
-
hasSubUnits,
|
|
10
|
-
isZero,
|
|
11
|
-
lessThan,
|
|
12
|
-
lessThanOrEqual,
|
|
13
|
-
maximum,
|
|
14
|
-
minimum,
|
|
15
|
-
multiply,
|
|
16
|
-
normalizeScale,
|
|
17
|
-
dinero,
|
|
18
|
-
dinero as money,
|
|
19
|
-
subtract,
|
|
20
|
-
toSnapshot,
|
|
21
|
-
toUnits,
|
|
22
|
-
toDecimal,
|
|
23
|
-
trimScale,
|
|
24
|
-
haveSameCurrency,
|
|
25
|
-
haveSameAmount,
|
|
26
|
-
dinero as currency
|
|
27
|
-
} from "dinero.js";
|
|
28
|
-
export { USD } from "@dinero.js/currencies";
|
package/dist/debounce.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { debounce } from 'perfect-debounce';
|
package/dist/debounce.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { debounce } from "perfect-debounce";
|
package/dist/delete.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { rimraf, rimraf as del } from 'rimraf';
|
package/dist/delete.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { rimraf, rimraf as del } from "rimraf";
|
package/dist/equal.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isDeepEqual(value1: any, value2: any): boolean;
|
package/dist/equal.mjs
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { getTypeName } from "./base.mjs";
|
|
2
|
-
export function isDeepEqual(value1, value2) {
|
|
3
|
-
const type1 = getTypeName(value1);
|
|
4
|
-
const type2 = getTypeName(value2);
|
|
5
|
-
if (type1 !== type2)
|
|
6
|
-
return false;
|
|
7
|
-
if (type1 === "array") {
|
|
8
|
-
if (value1.length !== value2.length)
|
|
9
|
-
return false;
|
|
10
|
-
return value1.every((item, i) => {
|
|
11
|
-
return isDeepEqual(item, value2[i]);
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
if (type1 === "object") {
|
|
15
|
-
const keyArr = Object.keys(value1);
|
|
16
|
-
if (keyArr.length !== Object.keys(value2).length)
|
|
17
|
-
return false;
|
|
18
|
-
return keyArr.every((key) => {
|
|
19
|
-
return isDeepEqual(value1[key], value2[key]);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return Object.is(value1, value2);
|
|
23
|
-
}
|
package/dist/function.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Fn, Nullable } from '@stacksjs/types';
|
|
2
|
-
/**
|
|
3
|
-
* Call every function in an array
|
|
4
|
-
*/
|
|
5
|
-
export declare function batchInvoke(functions: Nullable<Fn>[]): void;
|
|
6
|
-
/**
|
|
7
|
-
* Pass the value through the callback, and return the value
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```
|
|
11
|
-
* function createUser(name: string): User {
|
|
12
|
-
* return tap(new User, user => {
|
|
13
|
-
* user.name = name
|
|
14
|
-
* })
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare function tap<T>(value: T, callback: (value: T) => void): T;
|
package/dist/function.mjs
DELETED
package/dist/guards.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type guard to filter out null-ish values
|
|
3
|
-
*
|
|
4
|
-
* @category Guards
|
|
5
|
-
* @example array.filter(notNullish)
|
|
6
|
-
*/
|
|
7
|
-
export declare function notNullish<T>(v: T | null | undefined): v is NonNullable<T>;
|
|
8
|
-
/**
|
|
9
|
-
* Type guard to filter out null values
|
|
10
|
-
*
|
|
11
|
-
* @category Guards
|
|
12
|
-
* @example array.filter(noNull)
|
|
13
|
-
*/
|
|
14
|
-
export declare function noNull<T>(v: T | null): v is Exclude<T, null>;
|
|
15
|
-
/**
|
|
16
|
-
* Type guard to filter out null-ish values
|
|
17
|
-
*
|
|
18
|
-
* @category Guards
|
|
19
|
-
* @example array.filter(notUndefined)
|
|
20
|
-
*/
|
|
21
|
-
export declare function notUndefined<T>(v: T): v is Exclude<T, undefined>;
|
|
22
|
-
/**
|
|
23
|
-
* Type guard to filter out falsy values
|
|
24
|
-
*
|
|
25
|
-
* @category Guards
|
|
26
|
-
* @example array.filter(isTruthy)
|
|
27
|
-
*/
|
|
28
|
-
export declare function isTruthy<T>(v: T): v is NonNullable<T>;
|
package/dist/guards.mjs
DELETED
package/dist/helpers.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { AddressInfo } from 'node:net';
|
|
3
|
-
import type { CliOptions, CommandResult, Manifest, NpmScript } from '@stacksjs/types';
|
|
4
|
-
export declare function isProjectCreated(): Promise<boolean>;
|
|
5
|
-
export declare function installIfVersionMismatch(): Promise<void>;
|
|
6
|
-
export declare function frameworkVersion(): Promise<string>;
|
|
7
|
-
export declare function isAppKeySet(): Promise<boolean>;
|
|
8
|
-
/**
|
|
9
|
-
* Determines the utilized reset preset.
|
|
10
|
-
*
|
|
11
|
-
* @url https://www.npmjs.com/package/@unocss/reset
|
|
12
|
-
* @param preset
|
|
13
|
-
*/
|
|
14
|
-
export declare function determineResetPreset(preset?: string): string[];
|
|
15
|
-
/**
|
|
16
|
-
* Determines whether the specified value is a package manifest.
|
|
17
|
-
*/
|
|
18
|
-
export declare function isManifest(obj: any): obj is Manifest;
|
|
19
|
-
/**
|
|
20
|
-
* Determines whether the specified value is a string, null, or undefined.
|
|
21
|
-
*/
|
|
22
|
-
export declare function isOptionalString(value: any): value is string | undefined;
|
|
23
|
-
export declare function setEnvValue(key: string, value: string): Promise<void>;
|
|
24
|
-
/**
|
|
25
|
-
* Runs the specified NPM script in the package.json file.
|
|
26
|
-
*/
|
|
27
|
-
export declare function runNpmScript(script: NpmScript, options?: CliOptions): Promise<CommandResult>;
|
|
28
|
-
/**
|
|
29
|
-
* Determines whether the specified NPM script exists in the given manifest.
|
|
30
|
-
*/
|
|
31
|
-
export declare function hasScript(manifest: Manifest, script: NpmScript): boolean;
|
|
32
|
-
export declare function parseYaml(content: any): any;
|
|
33
|
-
/**
|
|
34
|
-
* Determines the level of debugging.
|
|
35
|
-
*
|
|
36
|
-
* The debug level is determined by the following:
|
|
37
|
-
* 1. The --verbose flag
|
|
38
|
-
* 2. The debug property in the app configuration
|
|
39
|
-
*
|
|
40
|
-
* Currently, we don't support a custom debug level,
|
|
41
|
-
* though, we would like to in the future.
|
|
42
|
-
*
|
|
43
|
-
* @param options
|
|
44
|
-
*/
|
|
45
|
-
export declare function determineDebugLevel(options?: CliOptions): boolean;
|
|
46
|
-
export declare function isIpv6(address: AddressInfo): boolean;
|
package/dist/helpers.mjs
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { frameworkPath, projectPath } from "@stacksjs/path";
|
|
2
|
-
import { parse } from "yaml";
|
|
3
|
-
import { execSync, log, runCommand, spawn } from "@stacksjs/cli";
|
|
4
|
-
import { app, ui } from "@stacksjs/config";
|
|
5
|
-
import * as storage from "@stacksjs/storage";
|
|
6
|
-
import { semver } from "./versions.mjs";
|
|
7
|
-
export async function isProjectCreated() {
|
|
8
|
-
if (storage.isFile(".env"))
|
|
9
|
-
return await isAppKeySet();
|
|
10
|
-
if (storage.isFile(".env.example"))
|
|
11
|
-
await spawn("cp .env.example .env", { stdio: "inherit", cwd: projectPath() });
|
|
12
|
-
return await isAppKeySet();
|
|
13
|
-
}
|
|
14
|
-
export async function installIfVersionMismatch() {
|
|
15
|
-
const dependenciesYaml = storage.fs.readFileSync(projectPath("tea.yaml"), "utf8");
|
|
16
|
-
const dependencies = parseYaml(dependenciesYaml).dependencies;
|
|
17
|
-
const requiredNodeVersion = dependencies["nodejs.org"];
|
|
18
|
-
const requiredPnpmVersion = dependencies["pnpm.io"];
|
|
19
|
-
const installedNodeVersion = process.version;
|
|
20
|
-
const installedPnpmVersion = execSync("pnpm -v").trim();
|
|
21
|
-
if (!semver.satisfies(installedNodeVersion, requiredNodeVersion)) {
|
|
22
|
-
log.error(`Installed Node.js version (${installedNodeVersion}) does not satisfy required version (${requiredNodeVersion}). One moment...`);
|
|
23
|
-
await runCommand(`tea +nodejs.org${requiredNodeVersion} >/dev/null 2>&1`);
|
|
24
|
-
}
|
|
25
|
-
if (!semver.satisfies(installedPnpmVersion, requiredPnpmVersion)) {
|
|
26
|
-
log.error(`Installed pnpm version (${installedPnpmVersion}) does not satisfy required version (${requiredPnpmVersion}). One moment...`);
|
|
27
|
-
await runCommand(`tea +pnpm.io${requiredPnpmVersion} >/dev/null 2>&1`);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export async function frameworkVersion() {
|
|
31
|
-
return (await storage.readPackageJson(frameworkPath("package.json"))).version;
|
|
32
|
-
}
|
|
33
|
-
export async function isAppKeySet() {
|
|
34
|
-
const env = await storage.readTextFile(".env", projectPath());
|
|
35
|
-
const lines = env.data.split("\n");
|
|
36
|
-
const appKey = lines.find((line) => line.startsWith("APP_KEY="));
|
|
37
|
-
return !!(appKey && appKey.length > 16);
|
|
38
|
-
}
|
|
39
|
-
export function determineResetPreset(preset) {
|
|
40
|
-
if (ui.reset)
|
|
41
|
-
preset = ui.reset;
|
|
42
|
-
if (preset === "tailwind")
|
|
43
|
-
return ["import '@unocss/reset/tailwind.css'"];
|
|
44
|
-
if (preset === "normalize")
|
|
45
|
-
return ["import '@unocss/reset/normalize.css'"];
|
|
46
|
-
if (preset === "sanitize")
|
|
47
|
-
return ["import '@unocss/reset/sanitize/sanitize.css'", "import '@unocss/reset/sanitize/assets.css"];
|
|
48
|
-
if (preset === "eric-meyer")
|
|
49
|
-
return ["import '@unocss/reset/eric-meyer.css'"];
|
|
50
|
-
if (preset === "antfu")
|
|
51
|
-
return ["import '@unocss/reset/antfu.css'"];
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
export function isManifest(obj) {
|
|
55
|
-
return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
|
|
56
|
-
}
|
|
57
|
-
export function isOptionalString(value) {
|
|
58
|
-
const type = typeof value;
|
|
59
|
-
return value === null || type === "undefined" || type === "string";
|
|
60
|
-
}
|
|
61
|
-
export async function setEnvValue(key, value) {
|
|
62
|
-
const file = await storage.readTextFile(projectPath(".env"));
|
|
63
|
-
await storage.writeTextFile({
|
|
64
|
-
path: projectPath(".env"),
|
|
65
|
-
data: file.data.replace(/APP_KEY=/g, `APP_KEY=${value}`)
|
|
66
|
-
// todo: do not hardcode the APP_KEY here and instead use the key parameter
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
export async function runNpmScript(script, options) {
|
|
70
|
-
const { data: manifest } = await storage.readJsonFile("package.json", frameworkPath());
|
|
71
|
-
if (isManifest(manifest) && hasScript(manifest, script))
|
|
72
|
-
return await runCommand(`pnpm run ${script}`, options);
|
|
73
|
-
log.error(`The specified npm script "${script}" does not exist in the package.json file`);
|
|
74
|
-
process.exit();
|
|
75
|
-
}
|
|
76
|
-
export function hasScript(manifest, script) {
|
|
77
|
-
const scripts = manifest.scripts;
|
|
78
|
-
if (scripts && typeof scripts === "object")
|
|
79
|
-
return Boolean(scripts[script]);
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
export function parseYaml(content) {
|
|
83
|
-
return parse(content);
|
|
84
|
-
}
|
|
85
|
-
export function determineDebugLevel(options) {
|
|
86
|
-
if (options?.verbose === true)
|
|
87
|
-
return true;
|
|
88
|
-
return app.debug === true;
|
|
89
|
-
}
|
|
90
|
-
export function isIpv6(address) {
|
|
91
|
-
return address.family === "IPv6" || address.family === 6;
|
|
92
|
-
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export * from './base';
|
|
2
|
-
export * from './config';
|
|
3
|
-
export * from './currency';
|
|
4
|
-
export * from './debounce';
|
|
5
|
-
export * from './delete';
|
|
6
|
-
export * from './equal';
|
|
7
|
-
export * from './function';
|
|
8
|
-
export * from './guards';
|
|
9
|
-
export * from './helpers';
|
|
10
|
-
export * from './math';
|
|
11
|
-
export * from './p';
|
|
12
|
-
export * from './promise';
|
|
13
|
-
export * from './throttle';
|
|
14
|
-
export * from './vendors';
|
|
15
|
-
export * from './versions';
|
package/dist/index.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export * from "./base.mjs";
|
|
2
|
-
export * from "./config.mjs";
|
|
3
|
-
export * from "./currency.mjs";
|
|
4
|
-
export * from "./debounce.mjs";
|
|
5
|
-
export * from "./delete.mjs";
|
|
6
|
-
export * from "./equal.mjs";
|
|
7
|
-
export * from "./function.mjs";
|
|
8
|
-
export * from "./guards.mjs";
|
|
9
|
-
export * from "./helpers.mjs";
|
|
10
|
-
export * from "./math.mjs";
|
|
11
|
-
export * from "./p.mjs";
|
|
12
|
-
export * from "./promise.mjs";
|
|
13
|
-
export * from "./throttle.mjs";
|
|
14
|
-
export * from "./vendors.mjs";
|
|
15
|
-
export * from "./versions.mjs";
|
package/dist/math.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const clamp: (n: number, min: number, max: number) => number;
|
|
2
|
-
export declare function rand(min: number, max: number): number;
|
|
3
|
-
export { and, createGenericProjection, createProjection, logicNot, logicOr, not, or, useAbs, useAverage, useCeil, useClamp, useFloor, useMath, useMax, useMin, usePrecision, useProjection, useRound, useSum, useTrunc, } from '@vueuse/math';
|