stacks 0.1.0 → 0.37.4
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/.gitignore +10 -0
- package/LICENSE.md +21 -0
- package/README.md +53 -104
- package/auto-imports.d.ts +826 -0
- package/bin/stacks.mjs +4 -0
- package/components.d.ts +22 -0
- package/core/actions/README.md +59 -0
- package/core/actions/node_modules/.bin/markdown-it +17 -0
- package/core/actions/node_modules/.bin/mkdist +17 -0
- package/core/actions/package.json +64 -0
- package/core/actions/src/copy-types.ts +22 -0
- package/core/actions/src/generate/component-meta.ts +94 -0
- package/core/actions/src/generate/index.ts +4 -0
- package/core/actions/src/generate/lib-entries.ts +106 -0
- package/core/actions/src/generate/package-json.ts +87 -0
- package/core/actions/src/generate/vscode-custom-data.ts +28 -0
- package/core/actions/src/generate/vue-compat.ts +17 -0
- package/core/actions/src/generate-component-meta.ts +19 -0
- package/core/actions/src/generate-ide-helpers.ts +23 -0
- package/core/actions/src/generate-lib-entries.ts +22 -0
- package/core/actions/src/generate-package-json.ts +15 -0
- package/core/actions/src/generate-vscode-custom-data.ts +20 -0
- package/core/actions/src/generate-vue-compat.ts +10 -0
- package/core/arrays/README.md +59 -0
- package/core/arrays/node_modules/.bin/mkdist +17 -0
- package/core/arrays/node_modules/.bin/tsc +17 -0
- package/core/arrays/node_modules/.bin/tsserver +17 -0
- package/core/arrays/package.json +50 -0
- package/core/arrays/src/index.ts +3 -0
- package/core/build/README.md +59 -0
- package/core/build/entries/README.md +7 -0
- package/core/build/node_modules/.bin/jiti +17 -0
- package/core/build/node_modules/.bin/mkdist +17 -0
- package/core/build/node_modules/.bin/vite +17 -0
- package/core/build/node_modules/.bin/vite-ssg +17 -0
- package/core/build/node_modules/.bin/vue-docgen-web-types +17 -0
- package/core/build/package.json +71 -0
- package/core/build/src/example-vue.ts +26 -0
- package/core/build/src/example-wc.ts +26 -0
- package/core/build/src/functions.ts +56 -0
- package/core/build/src/index.ts +7 -0
- package/core/build/src/pages.ts +50 -0
- package/core/build/src/stacks.ts +204 -0
- package/core/build/src/vue-components.ts +76 -0
- package/core/build/src/web-components.ts +63 -0
- package/core/build/web-types.config.cjs +4 -0
- package/core/build/web-types.ts +14 -0
- package/core/collections/README.md +59 -0
- package/core/collections/node_modules/.bin/mkdist +17 -0
- package/core/collections/node_modules/.bin/tsc +17 -0
- package/core/collections/node_modules/.bin/tsserver +17 -0
- package/core/collections/package.json +54 -0
- package/core/collections/src/index.ts +1 -0
- package/core/fs/README.md +59 -0
- package/core/fs/node_modules/.bin/mkdist +17 -0
- package/core/fs/package.json +56 -0
- package/core/fs/src/index.ts +170 -0
- package/core/helpers/node_modules/.bin/mkdist +17 -0
- package/core/helpers/package.json +58 -0
- package/core/helpers/src/index.ts +129 -0
- package/core/modules/README.md +61 -0
- package/core/modules/node_modules/.bin/mkdist +17 -0
- package/core/modules/package.json +51 -0
- package/core/modules/src/i18n.ts +23 -0
- package/core/modules/src/nprogress.ts +12 -0
- package/core/modules/src/pwa.ts +12 -0
- package/core/objects/README.md +59 -0
- package/core/objects/node_modules/.bin/mkdist +17 -0
- package/core/objects/node_modules/.bin/tsc +17 -0
- package/core/objects/node_modules/.bin/tsserver +17 -0
- package/core/objects/package.json +51 -0
- package/core/objects/src/index.ts +1 -0
- package/core/paths/node_modules/.bin/mkdist +17 -0
- package/core/paths/node_modules/.bin/tsc +17 -0
- package/core/paths/node_modules/.bin/tsserver +17 -0
- package/core/paths/package.json +51 -0
- package/core/paths/src/index.ts +178 -0
- package/core/router/README.md +59 -0
- package/core/router/node_modules/.bin/mkdist +17 -0
- package/core/router/package.json +51 -0
- package/core/router/src/index.ts +14 -0
- package/core/security/README.md +59 -0
- package/core/security/node_modules/.bin/mkdist +17 -0
- package/core/security/package.json +56 -0
- package/core/security/src/crypt.ts +14 -0
- package/core/security/src/hash.ts +52 -0
- package/core/security/src/index.ts +3 -0
- package/core/security/src/key.ts +11 -0
- package/core/strings/README.md +59 -0
- package/core/strings/node_modules/.bin/mkdist +17 -0
- package/core/strings/node_modules/.bin/tsc +17 -0
- package/core/strings/node_modules/.bin/tsserver +17 -0
- package/core/strings/package.json +63 -0
- package/core/strings/src/index.ts +14 -0
- package/core/types/README.md +59 -0
- package/core/types/node_modules/.bin/markdown-it +17 -0
- package/core/types/node_modules/.bin/mkdist +17 -0
- package/core/types/node_modules/.bin/vite +17 -0
- package/core/types/node_modules/.bin/vitepress +17 -0
- package/core/types/package.json +60 -0
- package/core/types/src/app.ts +131 -0
- package/core/types/src/auto-imports.ts +3 -0
- package/core/types/src/build.ts +3 -0
- package/core/types/src/cli.ts +49 -0
- package/core/types/src/components.ts +66 -0
- package/core/types/src/deploy.ts +11 -0
- package/core/types/src/docs.ts +3 -0
- package/core/types/src/exit-code.ts +10 -0
- package/core/types/src/fs.ts +17 -0
- package/core/types/src/git.ts +131 -0
- package/core/types/src/hashing.ts +107 -0
- package/core/types/src/i18n.ts +19 -0
- package/core/types/src/index.ts +21 -0
- package/core/types/src/inspect.ts +10 -0
- package/core/types/src/layout.ts +8 -0
- package/core/types/src/library.ts +148 -0
- package/core/types/src/manifest.ts +9 -0
- package/core/types/src/markdown.ts +198 -0
- package/core/types/src/pages.ts +8 -0
- package/core/types/src/pwa.ts +8 -0
- package/core/types/src/ssg.ts +3 -0
- package/core/types/src/ui.ts +141 -0
- package/core/ui/README.md +60 -0
- package/core/ui/node_modules/.bin/mkdist +17 -0
- package/core/ui/node_modules/.bin/tsc +17 -0
- package/core/ui/node_modules/.bin/tsserver +17 -0
- package/core/ui/node_modules/.bin/vue-tsc +17 -0
- package/core/ui/package.json +62 -0
- package/core/ui/src/index.ts +60 -0
- package/custom-elements.json +14 -0
- package/examples/vue-components/App.vue +12 -0
- package/examples/vue-components/favicon.png +0 -0
- package/examples/vue-components/index.html +20 -0
- package/examples/web-components/favicon.png +0 -0
- package/examples/web-components/index.html +13 -0
- package/functions/node_modules/.bin/artisan +17 -0
- package/functions/node_modules/.bin/stacks +17 -0
- package/functions/node_modules/.bin/stx +17 -0
- package/functions/package.json +40 -0
- package/netlify.toml +18 -0
- package/nitro.config.ts +6 -0
- package/package.json +224 -27
- package/pages/App.vue +26 -0
- package/pages/index.html +23 -0
- package/pages/main.ts +26 -0
- package/pages/public/_headers +3 -0
- package/pages/public/favicon-dark.svg +3 -0
- package/pages/public/favicon.svg +3 -0
- package/pages/public/pwa-192x192.png +0 -0
- package/pages/public/pwa-512x512.png +0 -0
- package/pages/public/safari-pinned-tab.svg +41 -0
- package/pages/styles/main.css +29 -0
- package/pages/styles/markdown.css +28 -0
- package/scripts/ensure-env.sh +248 -0
- package/shims.d.ts +29 -0
- package/simple-git-hooks.cjs +4 -0
- package/src/cli/actions/build.ts +160 -0
- package/src/cli/actions/commit.ts +9 -0
- package/src/cli/actions/dev.ts +47 -0
- package/src/cli/actions/examples.ts +74 -0
- package/src/cli/actions/fresh.ts +9 -0
- package/src/cli/actions/generate.ts +159 -0
- package/src/cli/actions/index.ts +12 -0
- package/src/cli/actions/key.ts +31 -0
- package/src/cli/actions/lint.ts +19 -0
- package/src/cli/actions/make.ts +116 -0
- package/src/cli/actions/release.ts +9 -0
- package/src/cli/actions/test.ts +39 -0
- package/src/cli/actions/types.ts +180 -0
- package/src/cli/actions/update.ts +90 -0
- package/src/cli/build.ts +49 -0
- package/src/cli/create.ts +71 -0
- package/src/cli/dev.ts +28 -0
- package/src/cli/example.ts +28 -0
- package/src/cli/generate.ts +64 -0
- package/src/cli/index.ts +13 -0
- package/src/cli/key.ts +12 -0
- package/src/cli/make.ts +47 -0
- package/src/cli/test.ts +24 -0
- package/src/cli/types.ts +18 -0
- package/src/cli/update.ts +17 -0
- package/src/cli/utility.ts +39 -0
- package/src/cli.ts +48 -0
- package/src/docs.ts +4 -0
- package/src/index.ts +22 -0
- package/tsconfig.json +96 -0
- package/vitest.config.ts +22 -0
- package/vue-components/dist/.gitkeep +0 -0
- package/vue-components/index.html +13 -0
- package/vue-components/main.ts +18 -0
- package/vue-components/node_modules/.bin/artisan +17 -0
- package/vue-components/node_modules/.bin/stacks +17 -0
- package/vue-components/node_modules/.bin/stx +17 -0
- package/vue-components/package.json +40 -0
- package/web-components/dist/.gitkeep +0 -0
- package/web-components/node_modules/.bin/artisan +17 -0
- package/web-components/node_modules/.bin/stacks +17 -0
- package/web-components/node_modules/.bin/stx +17 -0
- package/web-components/package.json +40 -0
- package/web-types.json +67 -0
- package/.npmignore +0 -1
- package/.travis.yml +0 -4
- package/examples/stringReverse.js +0 -41
- package/examples/sumServer.js +0 -21
- package/examples/sumWorker.js +0 -23
- package/index.js +0 -1
- package/lib/stacks.js +0 -413
- package/test/test.stacks.js +0 -148
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
2
|
+
import { copyFileSync, existsSync, mkdirSync, readFile, readdirSync, rmSync, statSync, writeFile } from 'node:fs'
|
|
3
|
+
import detectIndent from 'detect-indent'
|
|
4
|
+
import { detectNewline } from 'detect-newline'
|
|
5
|
+
import type { JsonFile, TextFile } from '@stacksjs/types'
|
|
6
|
+
import { componentsPath, dirname, functionsPath, join, projectPath } from '@stacksjs/paths'
|
|
7
|
+
import { contains } from '@stacksjs/arrays'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Reads a JSON file and returns the parsed data.
|
|
11
|
+
*/
|
|
12
|
+
export async function readJsonFile(name: string, cwd: string): Promise<JsonFile> {
|
|
13
|
+
const file = await readTextFile(name, cwd)
|
|
14
|
+
const data = JSON.parse(file.data) as unknown
|
|
15
|
+
const indent = detectIndent(file.data).indent
|
|
16
|
+
const newline = detectNewline(file.data)
|
|
17
|
+
|
|
18
|
+
return { ...file, data, indent, newline }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Writes the given data to the specified JSON file.
|
|
23
|
+
*/
|
|
24
|
+
export async function writeJsonFile(file: JsonFile): Promise<void> {
|
|
25
|
+
let json = JSON.stringify(file.data, undefined, file.indent)
|
|
26
|
+
|
|
27
|
+
if (file.newline)
|
|
28
|
+
json += file.newline
|
|
29
|
+
|
|
30
|
+
return writeTextFile({ ...file, data: json })
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Reads a text file and returns its contents.
|
|
35
|
+
*/
|
|
36
|
+
export function readTextFile(name: string, cwd?: string): Promise<TextFile> {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
let filePath: string
|
|
39
|
+
|
|
40
|
+
if (cwd)
|
|
41
|
+
filePath = join(cwd, name)
|
|
42
|
+
else
|
|
43
|
+
filePath = name
|
|
44
|
+
|
|
45
|
+
readFile(filePath, 'utf8', (err, text) => {
|
|
46
|
+
if (err) {
|
|
47
|
+
reject(err)
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
resolve({
|
|
51
|
+
path: filePath,
|
|
52
|
+
data: text,
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Writes the given text to the specified file.
|
|
61
|
+
*/
|
|
62
|
+
export function writeTextFile(file: TextFile): Promise<void> {
|
|
63
|
+
return new Promise((resolve, reject) => {
|
|
64
|
+
writeFile(file.path, file.data, (err: any) => {
|
|
65
|
+
if (err)
|
|
66
|
+
reject(err)
|
|
67
|
+
|
|
68
|
+
else
|
|
69
|
+
resolve()
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Determine whether a path is a folder.
|
|
76
|
+
*/
|
|
77
|
+
export function isFolder(path: string): boolean {
|
|
78
|
+
try {
|
|
79
|
+
return statSync(path).isDirectory()
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return false
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Determine whether a path is a file.
|
|
88
|
+
*/
|
|
89
|
+
export function isFile(path: string): boolean {
|
|
90
|
+
return existsSync(projectPath(path))
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Determine whether a folder has any files in it.
|
|
95
|
+
*/
|
|
96
|
+
export function hasFiles(folder: string): boolean {
|
|
97
|
+
return readdirSync(folder).length > 0
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function hasComponents(): boolean {
|
|
101
|
+
return hasFiles(componentsPath())
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function hasFunctions(): boolean {
|
|
105
|
+
return hasFiles(functionsPath())
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function copyFolder(src: string, dest: string, exclude: string[] = []): void {
|
|
109
|
+
if (!existsSync(dest))
|
|
110
|
+
mkdirSync(dest, { recursive: true })
|
|
111
|
+
|
|
112
|
+
if (existsSync(src)) {
|
|
113
|
+
readdirSync(src).forEach((file) => {
|
|
114
|
+
if (!contains(join(src, file), exclude)) {
|
|
115
|
+
const srcPath = join(src, file)
|
|
116
|
+
const destPath = join(dest, file)
|
|
117
|
+
|
|
118
|
+
if (statSync(srcPath).isDirectory())
|
|
119
|
+
copyFolder(srcPath, destPath, exclude)
|
|
120
|
+
|
|
121
|
+
else
|
|
122
|
+
copyFileSync(srcPath, destPath)
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export async function deleteFolder(path: string) {
|
|
129
|
+
if (statSync(path).isDirectory())
|
|
130
|
+
await rmSync(path, { recursive: true, force: true })
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function deleteFiles(dir: string, exclude: string[] = []) {
|
|
134
|
+
if (existsSync(dir)) {
|
|
135
|
+
readdirSync(dir).forEach((file) => {
|
|
136
|
+
const path = join(dir, file)
|
|
137
|
+
if (statSync(path).isDirectory()) {
|
|
138
|
+
if (readdirSync(path).length === 0)
|
|
139
|
+
rmSync(path, { recursive: true, force: true })
|
|
140
|
+
|
|
141
|
+
else
|
|
142
|
+
deleteFiles(path, exclude)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
else if (!contains(path, exclude)) { rmSync(path) }
|
|
146
|
+
})
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function deleteEmptyFolders(dir: string) {
|
|
151
|
+
if (existsSync(dir)) {
|
|
152
|
+
readdirSync(dir).forEach((file) => {
|
|
153
|
+
const path = join(dir, file)
|
|
154
|
+
if (statSync(path).isDirectory()) {
|
|
155
|
+
if (readdirSync(path).length === 0)
|
|
156
|
+
rmSync(path, { recursive: true, force: true })
|
|
157
|
+
|
|
158
|
+
else deleteEmptyFolders(path)
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function doesFolderExist(path: string) {
|
|
165
|
+
return existsSync(path)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export const _dirname = typeof __dirname !== 'undefined'
|
|
169
|
+
? __dirname
|
|
170
|
+
: dirname(fileURLToPath(import.meta.url))
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="$NODE_PATH:/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/mkdist@0.3.13/node_modules/mkdist/dist/cli.cjs" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../../../../../node_modules/.pnpm/mkdist@0.3.13/node_modules/mkdist/dist/cli.cjs" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stacksjs/helpers",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.37.4",
|
|
5
|
+
"packageManager": "pnpm@7.13.6",
|
|
6
|
+
"description": "The Stacks helper functions.",
|
|
7
|
+
"author": "Chris Breuer",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"funding": "https://github.com/sponsors/chrisbbreuer",
|
|
10
|
+
"homepage": "https://github.com/stacksjs/stacks/tree/main/.stacks/core/helpers#readme",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/stacksjs/stacks.git",
|
|
14
|
+
"directory": "./.stacks/core/helpers"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/stacksjs/stacks/issues"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"objects",
|
|
21
|
+
"strings",
|
|
22
|
+
"arrays",
|
|
23
|
+
"alias",
|
|
24
|
+
"helpers",
|
|
25
|
+
"utilities",
|
|
26
|
+
"functions",
|
|
27
|
+
"stacks"
|
|
28
|
+
],
|
|
29
|
+
"main": "dist/index.mjs",
|
|
30
|
+
"module": "dist/index.mjs",
|
|
31
|
+
"types": "dist/index.d.ts",
|
|
32
|
+
"contributors": [
|
|
33
|
+
"Chris Breuer <chris@ow3.org>"
|
|
34
|
+
],
|
|
35
|
+
"files": [
|
|
36
|
+
"dist"
|
|
37
|
+
],
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=v18.10.0",
|
|
40
|
+
"pnpm": ">=7.13.6"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "mkdist -d",
|
|
44
|
+
"dev": "mkdist -d",
|
|
45
|
+
"prepublishOnly": "pnpm run build",
|
|
46
|
+
"typecheck": "tsc --noEmit"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@jsdevtools/ez-spawn": "^3.0.4",
|
|
50
|
+
"@stacksjs/fs": "workspace:*",
|
|
51
|
+
"@stacksjs/paths": "workspace:*",
|
|
52
|
+
"@stacksjs/types": "workspace:*",
|
|
53
|
+
"consola": "^2.15.3"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"mkdist": "^0.3.13"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import consola from 'consola'
|
|
2
|
+
import { ExitCode, type Manifest, type NpmScript } from '@stacksjs/types'
|
|
3
|
+
import { frameworkPath, projectPath } from '@stacksjs/paths'
|
|
4
|
+
import { isFile, readJsonFile, readTextFile, writeTextFile } from '@stacksjs/fs'
|
|
5
|
+
import ezSpawn from '@jsdevtools/ez-spawn'
|
|
6
|
+
import { ui } from '../../../config'
|
|
7
|
+
|
|
8
|
+
export async function isProjectCreated() {
|
|
9
|
+
if (isFile('.env'))
|
|
10
|
+
return await isAppKeySet()
|
|
11
|
+
|
|
12
|
+
if (isFile('.env.example'))
|
|
13
|
+
await ezSpawn.async('cp .env.example .env', { stdio: 'inherit', cwd: projectPath() })
|
|
14
|
+
|
|
15
|
+
return await isAppKeySet()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function isAppKeySet() {
|
|
19
|
+
const env = await readTextFile('.env', projectPath())
|
|
20
|
+
const lines = env.data.split('\n')
|
|
21
|
+
const appKey = lines.find(line => line.startsWith('APP_KEY='))
|
|
22
|
+
|
|
23
|
+
if (appKey && appKey.length > 16)
|
|
24
|
+
return true
|
|
25
|
+
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Determines the utilized reset preset.
|
|
31
|
+
*
|
|
32
|
+
* @url https://www.npmjs.com/package/@unocss/reset
|
|
33
|
+
* @param preset
|
|
34
|
+
*/
|
|
35
|
+
export function determineResetPreset(preset?: string) {
|
|
36
|
+
if (ui.reset)
|
|
37
|
+
preset = ui.reset
|
|
38
|
+
|
|
39
|
+
if (preset === 'tailwind')
|
|
40
|
+
return ['import \'@unocss/reset/tailwind.css\'']
|
|
41
|
+
|
|
42
|
+
if (preset === 'normalize')
|
|
43
|
+
return ['import \'@unocss/reset/normalize.css\'']
|
|
44
|
+
|
|
45
|
+
if (preset === 'sanitize')
|
|
46
|
+
return ['import \'@unocss/reset/sanitize/sanitize.css\'', 'import \'@unocss/reset/sanitize/assets.css']
|
|
47
|
+
|
|
48
|
+
if (preset === 'eric-meyer')
|
|
49
|
+
return ['import \'@unocss/reset/eric-meyer.css\'']
|
|
50
|
+
|
|
51
|
+
if (preset === 'antfu')
|
|
52
|
+
return ['import \'@unocss/reset/antfu.css\'']
|
|
53
|
+
|
|
54
|
+
return []
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function env(key?: string, fallback?: any) {
|
|
58
|
+
// console.log('isClient', isClient)
|
|
59
|
+
// if (key && import.meta?.env)
|
|
60
|
+
// return import.meta.env[key]
|
|
61
|
+
|
|
62
|
+
return fallback
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function config(key?: string, fallback?: string) {
|
|
66
|
+
// eslint-disable-next-line no-console
|
|
67
|
+
console.log('key', key, 'fallback', fallback)
|
|
68
|
+
// return key ? configArr[key as string] : fallback
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Determines whether the specified value is a package manifest.
|
|
73
|
+
*/
|
|
74
|
+
export function isManifest(obj: any): obj is Manifest {
|
|
75
|
+
return obj
|
|
76
|
+
&& typeof obj === 'object'
|
|
77
|
+
&& isOptionalString(obj.name)
|
|
78
|
+
&& isOptionalString(obj.version)
|
|
79
|
+
&& isOptionalString(obj.description)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Determines whether the specified value is a string, null, or undefined.
|
|
84
|
+
*/
|
|
85
|
+
function isOptionalString(value: any): value is string | undefined {
|
|
86
|
+
const type = typeof value
|
|
87
|
+
return value === null
|
|
88
|
+
|| type === 'undefined'
|
|
89
|
+
|| type === 'string'
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export async function setEnvValue(key: string, value: string) {
|
|
93
|
+
const file = await readTextFile(projectPath('.env'))
|
|
94
|
+
|
|
95
|
+
await writeTextFile({
|
|
96
|
+
path: projectPath('.env'),
|
|
97
|
+
data: file.data.replace(/APP_KEY=/g, `APP_KEY=${value}`), // todo: do not hardcode the APP_KEY here and instead use the key parameter
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Runs the specified NPM script in the package.json file.
|
|
103
|
+
*/
|
|
104
|
+
export async function runNpmScript(script: NpmScript, debug: 'ignore' | 'inherit' = 'inherit') {
|
|
105
|
+
const path = frameworkPath()
|
|
106
|
+
|
|
107
|
+
const { data: manifest } = await readJsonFile('package.json', path)
|
|
108
|
+
|
|
109
|
+
if (isManifest(manifest) && hasScript(manifest, script)) {
|
|
110
|
+
await ezSpawn.async('pnpm', ['run', script], { stdio: debug, cwd: path })
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
else {
|
|
114
|
+
consola.error('Error running your Artisan script.')
|
|
115
|
+
process.exit(ExitCode.FatalError)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Determines whether the specified NPM script exists in the given manifest.
|
|
121
|
+
*/
|
|
122
|
+
export function hasScript(manifest: Manifest, script: NpmScript): boolean {
|
|
123
|
+
const scripts = manifest.scripts as Record<NpmScript, string> | undefined
|
|
124
|
+
|
|
125
|
+
if (scripts && typeof scripts === 'object')
|
|
126
|
+
return Boolean(scripts[script])
|
|
127
|
+
|
|
128
|
+
return false
|
|
129
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Stacks Modules
|
|
2
|
+
|
|
3
|
+
A custom user module system. Place a `.ts` file with the following template & it will be installed automatically.
|
|
4
|
+
|
|
5
|
+
## ☘️ Features
|
|
6
|
+
|
|
7
|
+
wip
|
|
8
|
+
|
|
9
|
+
- ⚡️
|
|
10
|
+
|
|
11
|
+
wip
|
|
12
|
+
|
|
13
|
+
## 🤖 Usage
|
|
14
|
+
|
|
15
|
+
wip
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm i -D @stacksjs/modules
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Now, you can use it in your project:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { type UserModule } from '@stacksjs/types'
|
|
25
|
+
|
|
26
|
+
export const install: UserModule = ({ app, router, isClient }) => {
|
|
27
|
+
// do something
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Learn more in the docs.
|
|
32
|
+
|
|
33
|
+
## 🧪 Testing
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pnpm test
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 📈 Changelog
|
|
40
|
+
|
|
41
|
+
Please see our [releases](https://github.com/stacksjs/stacksjs/releases) page for more information on what has changed recently.
|
|
42
|
+
|
|
43
|
+
## 💪🏼 Contributing
|
|
44
|
+
|
|
45
|
+
Please see [CONTRIBUTING](../../.github/CONTRIBUTING.md) for details.
|
|
46
|
+
|
|
47
|
+
## 🏝 Community
|
|
48
|
+
|
|
49
|
+
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
|
|
50
|
+
|
|
51
|
+
[Discussions on GitHub](https://github.com/stacksjs/stacks/discussions)
|
|
52
|
+
|
|
53
|
+
For casual chit-chat with others using this package:
|
|
54
|
+
|
|
55
|
+
[Join the Open Web Discord Server](https://discord.ow3.org)
|
|
56
|
+
|
|
57
|
+
## 📄 License
|
|
58
|
+
|
|
59
|
+
The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/stacks/tree/main/LICENSE.md) for more information.
|
|
60
|
+
|
|
61
|
+
Made with ❤️
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="$NODE_PATH:/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/mkdist@0.3.13/node_modules/mkdist/dist/cli.cjs" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../../../../../node_modules/.pnpm/mkdist@0.3.13/node_modules/mkdist/dist/cli.cjs" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stacksjs/modules",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.37.4",
|
|
5
|
+
"packageManager": "pnpm@7.13.6",
|
|
6
|
+
"description": "The Stacks framework modules.",
|
|
7
|
+
"author": "Chris Breuer",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"funding": "https://github.com/sponsors/chrisbbreuer",
|
|
10
|
+
"homepage": "https://github.com/stacksjs/stacks/tree/main/.stacks/core/modules#readme",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/stacksjs/stacks.git",
|
|
14
|
+
"directory": "./.stacks/core/modules"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/stacksjs/stacks/issues"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"modules",
|
|
21
|
+
"stacks",
|
|
22
|
+
"framework",
|
|
23
|
+
"typescript",
|
|
24
|
+
"javascript"
|
|
25
|
+
],
|
|
26
|
+
"contributors": [
|
|
27
|
+
"Chris Breuer <chris@ow3.org>"
|
|
28
|
+
],
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=v18.10.0",
|
|
34
|
+
"pnpm": ">=7.13.6"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "mkdist -d",
|
|
38
|
+
"dev": "mkdist -d",
|
|
39
|
+
"prepublishOnly": "pnpm run build",
|
|
40
|
+
"typecheck": "tsc --noEmit"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@stacksjs/types": "workspace:*",
|
|
44
|
+
"@types/nprogress": "^0.2.0",
|
|
45
|
+
"nprogress": "^0.2.0",
|
|
46
|
+
"vue-i18n": "^9.2.2"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"mkdist": "^0.3.13"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createI18n } from 'vue-i18n'
|
|
2
|
+
import { type UserModule } from '@stacksjs/types'
|
|
3
|
+
|
|
4
|
+
// Import i18n resources
|
|
5
|
+
// https://vitejs.dev/guide/features.html#glob-import
|
|
6
|
+
const messages = Object.fromEntries(
|
|
7
|
+
Object.entries(
|
|
8
|
+
import.meta.glob<{ default: any }>(langPath('*.y(a)?ml'), { eager: true }))
|
|
9
|
+
.map(([key, value]) => {
|
|
10
|
+
const yaml = key.endsWith('.yaml')
|
|
11
|
+
return [key.slice(14, yaml ? -5 : -4), value.default]
|
|
12
|
+
}),
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
export const install: UserModule = ({ app }) => {
|
|
16
|
+
const i18n = createI18n({
|
|
17
|
+
legacy: false,
|
|
18
|
+
locale: 'en',
|
|
19
|
+
messages,
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
app.use(i18n)
|
|
23
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import NProgress from 'nprogress'
|
|
2
|
+
import { type UserModule } from '@stacksjs/types'
|
|
3
|
+
|
|
4
|
+
export const install: UserModule = ({ isClient, router }) => {
|
|
5
|
+
if (isClient) {
|
|
6
|
+
router.beforeEach((to, from) => {
|
|
7
|
+
if (to.path !== from.path)
|
|
8
|
+
NProgress.start()
|
|
9
|
+
})
|
|
10
|
+
router.afterEach(() => { NProgress.done() })
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type UserModule } from '@stacksjs/types'
|
|
2
|
+
|
|
3
|
+
// https://github.com/antfu/vite-plugin-pwa#automatic-reload-when-new-content-available
|
|
4
|
+
export const install: UserModule = ({ isClient, router }) => {
|
|
5
|
+
if (!isClient)
|
|
6
|
+
return
|
|
7
|
+
|
|
8
|
+
router.isReady().then(async () => {
|
|
9
|
+
const { registerSW } = await import('virtual:pwa-register')
|
|
10
|
+
registerSW({ immediate: true })
|
|
11
|
+
})
|
|
12
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Stacks Objects
|
|
2
|
+
|
|
3
|
+
This package contains the Stacks Objects source.
|
|
4
|
+
|
|
5
|
+
## ☘️ Features
|
|
6
|
+
|
|
7
|
+
wip
|
|
8
|
+
|
|
9
|
+
- ⚡️
|
|
10
|
+
|
|
11
|
+
wip
|
|
12
|
+
|
|
13
|
+
## 🤖 Usage
|
|
14
|
+
|
|
15
|
+
wip
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm i -D @stacksjs/objects
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Now, you can use it in your project:
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import * as objects from '@stacksjs/objects'
|
|
25
|
+
|
|
26
|
+
// wip
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Learn more in the docs.
|
|
30
|
+
|
|
31
|
+
## 🧪 Testing
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pnpm test
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 📈 Changelog
|
|
38
|
+
|
|
39
|
+
Please see our [releases](https://github.com/stacksjs/stacksjs/releases) page for more information on what has changed recently.
|
|
40
|
+
|
|
41
|
+
## 💪🏼 Contributing
|
|
42
|
+
|
|
43
|
+
Please see [CONTRIBUTING](../../.github/CONTRIBUTING.md) for details.
|
|
44
|
+
|
|
45
|
+
## 🏝 Community
|
|
46
|
+
|
|
47
|
+
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
|
|
48
|
+
|
|
49
|
+
[Discussions on GitHub](https://github.com/stacksjs/stacks/discussions)
|
|
50
|
+
|
|
51
|
+
For casual chit-chat with others using this package:
|
|
52
|
+
|
|
53
|
+
[Join the Open Web Discord Server](https://discord.ow3.org)
|
|
54
|
+
|
|
55
|
+
## 📄 License
|
|
56
|
+
|
|
57
|
+
The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/stacks/tree/main/LICENSE.md) for more information.
|
|
58
|
+
|
|
59
|
+
Made with ❤️
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="$NODE_PATH:/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/mkdist@0.3.13_typescript@4.8.4/node_modules/mkdist/dist/cli.cjs" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../../../../../node_modules/.pnpm/mkdist@0.3.13_typescript@4.8.4/node_modules/mkdist/dist/cli.cjs" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="$NODE_PATH:/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/typescript@4.8.4/node_modules/typescript/bin/tsc" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../../../../../node_modules/.pnpm/typescript@4.8.4/node_modules/typescript/bin/tsc" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="$NODE_PATH:/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/typescript@4.8.4/node_modules/typescript/bin/tsserver" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../../../../../node_modules/.pnpm/typescript@4.8.4/node_modules/typescript/bin/tsserver" "$@"
|
|
17
|
+
fi
|