@stacksjs/actions 0.70.258 → 0.70.260
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/action.js +1 -80
- package/dist/actions.js +1 -2
- package/dist/add.js +1 -20
- package/dist/ai/request-model-access.js +1 -10
- package/dist/auth/client.js +2 -44
- package/dist/auth/prune.js +1 -35
- package/dist/auth/setup.js +33 -153
- package/dist/auth/token.js +1 -10
- package/dist/blog-admin.js +3 -151
- package/dist/blog.js +33 -271
- package/dist/build/cli.js +1 -6
- package/dist/build/component-library.js +1 -36
- package/dist/build/component-libs.js +1 -2
- package/dist/build/core.js +1 -55
- package/dist/build/desktop.js +4 -61
- package/dist/build/dmg.js +4 -68
- package/dist/build/docs.js +1 -5
- package/dist/build/frontend-static.js +6 -122
- package/dist/build/server.js +1 -6
- package/dist/build/stacks.js +1 -8
- package/dist/build/views.js +1 -16
- package/dist/build-web-component-lib.js +1 -2
- package/dist/build.js +1 -57
- package/dist/bump.js +9 -210
- package/dist/changelog.js +1 -27
- package/dist/check/ports.js +1 -16
- package/dist/clean.js +1 -4
- package/dist/commit.js +1 -12
- package/dist/copy-types.js +1 -9
- package/dist/database/seed.js +1 -26
- package/dist/deploy/create-receipt-rule.js +1 -36
- package/dist/deploy/index.js +29 -1306
- package/dist/dev/api.js +3 -94
- package/dist/dev/components.js +1 -7
- package/dist/dev/csrf.js +1 -28
- package/dist/dev/dashboard-request-routing.js +1 -10
- package/dist/dev/dashboard-utils.js +1 -380
- package/dist/dev/dashboard.js +7 -422
- package/dist/dev/desktop.js +1 -1
- package/dist/dev/docs.js +1 -24
- package/dist/dev/exit-with-parent.d.ts +6 -0
- package/dist/dev/exit-with-parent.js +1 -0
- package/dist/dev/index.js +1 -29
- package/dist/dev/migrate-watcher.js +1 -74
- package/dist/dev/system-tray.js +2 -172
- package/dist/dev/views.js +1 -169
- package/dist/discover-packages.js +1 -32
- package/dist/domains/add.js +1 -61
- package/dist/domains/purchase.js +1 -66
- package/dist/domains/remove.js +1 -24
- package/dist/examples.js +1 -34
- package/dist/find-projects.js +1 -16
- package/dist/fresh.js +1 -17
- package/dist/generate/action-types.js +3 -9
- package/dist/generate/component-meta.js +1 -9
- package/dist/generate/custom-cli-file.js +2 -20
- package/dist/generate/env-files.js +5 -46
- package/dist/generate/ide-helpers.js +1 -8
- package/dist/generate/images.js +1 -26
- package/dist/generate/index.js +1 -166
- package/dist/generate/lib-entries.js +1 -16
- package/dist/generate/pantry-file.js +1 -46
- package/dist/generate/symlink-core.js +1 -2
- package/dist/generate/types.js +1 -3
- package/dist/generate/vschema.js +2 -47
- package/dist/generate/vscode-custom-data.js +1 -9
- package/dist/helpers/api-host.js +1 -7
- package/dist/helpers/component-meta.js +5 -295
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/lib-entries.js +3 -73
- package/dist/helpers/package-json.js +2 -34
- package/dist/helpers/utils.js +1 -130
- package/dist/helpers/vscode-custom-data.js +3 -57
- package/dist/index.js +1 -51
- package/dist/key-generate.js +1 -24
- package/dist/lint/fix.js +1 -4
- package/dist/lint/index.js +1 -4
- package/dist/lint/lint.js +1 -34
- package/dist/lint/stx-gate.js +3 -175
- package/dist/make-command.js +4 -55
- package/dist/make-job.js +3 -29
- package/dist/make-policy.js +4 -53
- package/dist/make-resource.js +3 -33
- package/dist/make.js +7 -323
- package/dist/migrate/database.js +1 -16
- package/dist/migrate/fresh.js +1 -36
- package/dist/prepublish.js +1 -16
- package/dist/queue/clear.js +1 -42
- package/dist/queue/dlq-purge.js +1 -28
- package/dist/queue/dlq-retry.js +1 -35
- package/dist/queue/dlq.js +4 -55
- package/dist/queue/failed.js +4 -69
- package/dist/queue/flush.js +2 -49
- package/dist/queue/inspect.js +7 -154
- package/dist/queue/list.js +4 -69
- package/dist/queue/monitor.js +5 -94
- package/dist/queue/pause.js +1 -28
- package/dist/queue/quarantine.js +2 -42
- package/dist/queue/resume.js +1 -27
- package/dist/queue/retry.js +1 -41
- package/dist/queue/schedule-list.js +4 -33
- package/dist/queue/schedule.js +1 -12
- package/dist/queue/status.js +4 -68
- package/dist/queue/table.js +1 -10
- package/dist/queue/unquarantine.js +1 -27
- package/dist/queue/work.js +1 -57
- package/dist/release-preflight.js +3 -61
- package/dist/release.js +1 -29
- package/dist/route/list.js +2 -78
- package/dist/run-action.js +1 -1
- package/dist/saas/setup.js +1 -9
- package/dist/scaffold-crud.js +12 -137
- package/dist/schedule/run.js +1 -7
- package/dist/search/flush.js +1 -10
- package/dist/search/import.js +1 -10
- package/dist/search/settings-list.js +1 -10
- package/dist/search/settings.js +1 -9
- package/dist/serve/api.js +1 -37
- package/dist/setup/index.js +1 -1
- package/dist/setup/ssl.js +2 -268
- package/dist/stacks.js +1 -316
- package/dist/templates.js +20 -40
- package/dist/test/feature.js +1 -2
- package/dist/test/index.js +1 -2
- package/dist/test/runner.js +1 -38
- package/dist/test/runner.test.js +1 -29
- package/dist/test/ui.js +1 -2
- package/dist/test/unit.js +1 -2
- package/dist/typecheck.js +1 -4
- package/dist/types.js +1 -16
- package/dist/upgrade/binary.js +1 -29
- package/dist/upgrade/framework-hooks.js +1 -40
- package/dist/upgrade/framework-utils.js +2 -259
- package/dist/upgrade/framework.js +11 -484
- package/dist/upgrade/index.js +1 -17
- package/dist/upgrade/package-project.js +1 -150
- package/dist/upgrade/packages.js +17 -243
- package/dist/upgrade/shell.js +3 -40
- package/dist/upgrade.js +1 -38
- package/package.json +18 -18
package/dist/stacks.js
CHANGED
|
@@ -1,316 +1 @@
|
|
|
1
|
-
import { mkdtempSync, rmSync } from "
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
4
|
-
import process from "node:process";
|
|
5
|
-
import { log } from "@stacksjs/logging";
|
|
6
|
-
import { registry } from "@stacksjs/registry";
|
|
7
|
-
import { copyFile, createFolder, deleteFile, deleteEmptyFolders, doesFolderExist, fs } from "@stacksjs/storage";
|
|
8
|
-
const STACK_DIRS = ["app", "config", "database", "resources", "routes", "public", "locales", "docs"];
|
|
9
|
-
function stackLockPath(projectRoot) {
|
|
10
|
-
return join(projectRoot, "storage", "framework", "stacks.lock.json");
|
|
11
|
-
}
|
|
12
|
-
function stackBackupPath(projectRoot, stackName) {
|
|
13
|
-
return join(projectRoot, "storage", "framework", "stacks", "backups", stackName);
|
|
14
|
-
}
|
|
15
|
-
async function readStackLock(projectRoot) {
|
|
16
|
-
const lockPath = stackLockPath(projectRoot);
|
|
17
|
-
try {
|
|
18
|
-
if (fs.existsSync(lockPath)) {
|
|
19
|
-
const content = await Bun.file(lockPath).text();
|
|
20
|
-
return JSON.parse(content);
|
|
21
|
-
}
|
|
22
|
-
} catch {}
|
|
23
|
-
return {
|
|
24
|
-
version: 1,
|
|
25
|
-
generatedAt: new Date().toISOString(),
|
|
26
|
-
stacks: {}
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
async function writeStackLock(projectRoot, lock) {
|
|
30
|
-
const lockPath = stackLockPath(projectRoot), lockDir = dirname(lockPath);
|
|
31
|
-
if (!fs.existsSync(lockDir))
|
|
32
|
-
await createFolder(lockDir);
|
|
33
|
-
lock.generatedAt = new Date().toISOString();
|
|
34
|
-
await Bun.write(lockPath, JSON.stringify(lock, null, 2));
|
|
35
|
-
}
|
|
36
|
-
function resolveProjectRoot(project) {
|
|
37
|
-
return resolve(project || process.cwd());
|
|
38
|
-
}
|
|
39
|
-
function resolveRegistryEntry(name) {
|
|
40
|
-
const entry = registry.find((candidate) => {
|
|
41
|
-
if (typeof candidate === "string")
|
|
42
|
-
return candidate === name;
|
|
43
|
-
return candidate.name === name || candidate.package === name;
|
|
44
|
-
});
|
|
45
|
-
if (!entry || typeof entry === "string")
|
|
46
|
-
return null;
|
|
47
|
-
if (!entry.github)
|
|
48
|
-
return null;
|
|
49
|
-
return { name: entry.name, github: entry.github, package: entry.package };
|
|
50
|
-
}
|
|
51
|
-
async function checkoutRegistryStack(github) {
|
|
52
|
-
const tempRoot = mkdtempSync(join(tmpdir(), "stacks-stack-")), checkoutPath = join(tempRoot, "source"), source = `https://github.com/${github}.git`;
|
|
53
|
-
if (await Bun.spawn(["git", "clone", "--depth", "1", "--quiet", source, checkoutPath], {
|
|
54
|
-
stdout: "inherit",
|
|
55
|
-
stderr: "inherit"
|
|
56
|
-
}).exited !== 0) {
|
|
57
|
-
rmSync(tempRoot, { recursive: !0, force: !0 });
|
|
58
|
-
throw Error(`Could not pull ${source}`);
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
path: checkoutPath,
|
|
62
|
-
cleanup: () => rmSync(tempRoot, { recursive: !0, force: !0 })
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function isSafeStackDirectory(directory) {
|
|
66
|
-
return directory.length > 0 && !isAbsolute(directory) && !directory.includes("..") && !directory.includes("\\");
|
|
67
|
-
}
|
|
68
|
-
function fileChecksum(path) {
|
|
69
|
-
return new Bun.CryptoHasher("sha256").update(fs.readFileSync(path)).digest("hex");
|
|
70
|
-
}
|
|
71
|
-
function collectFiles(dir, baseDir) {
|
|
72
|
-
const files = [];
|
|
73
|
-
if (!fs.existsSync(dir))
|
|
74
|
-
return files;
|
|
75
|
-
const entries = fs.readdirSync(dir, { withFileTypes: !0 });
|
|
76
|
-
for (const entry of entries) {
|
|
77
|
-
const fullPath = join(dir, entry.name);
|
|
78
|
-
if (entry.isDirectory())
|
|
79
|
-
files.push(...collectFiles(fullPath, baseDir));
|
|
80
|
-
else if (entry.isSymbolicLink())
|
|
81
|
-
throw Error(`Stack contains an unsupported symbolic link: ${relative(baseDir, fullPath)}`);
|
|
82
|
-
else {
|
|
83
|
-
const relPath = relative(baseDir, fullPath);
|
|
84
|
-
if (!isSafeStackDirectory(relPath))
|
|
85
|
-
throw Error(`Stack contains an unsafe path: ${relPath}`);
|
|
86
|
-
files.push(relPath);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return files;
|
|
90
|
-
}
|
|
91
|
-
export async function installStack(options) {
|
|
92
|
-
const { name, force = !1, dryRun = !1, verbose = !1 } = options, conflict = force ? "overwrite" : options.conflict ?? "skip", projectRoot = resolveProjectRoot(options.project);
|
|
93
|
-
log.info(`Installing stack "${name}"...`);
|
|
94
|
-
if (!fs.existsSync(join(projectRoot, "package.json"))) {
|
|
95
|
-
log.error(`No Stacks project found at "${projectRoot}"`);
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
const registryEntry = resolveRegistryEntry(name);
|
|
99
|
-
if (!registryEntry) {
|
|
100
|
-
log.error(`Stack "${name}" is not in the Stacks registry. Run "buddy stack:list" to see available stacks.`);
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
let checkout;
|
|
104
|
-
try {
|
|
105
|
-
checkout = await checkoutRegistryStack(registryEntry.github);
|
|
106
|
-
} catch (error) {
|
|
107
|
-
log.error(error instanceof Error ? error.message : String(error));
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
try {
|
|
111
|
-
const stackPath = checkout.path;
|
|
112
|
-
let pkg, meta;
|
|
113
|
-
try {
|
|
114
|
-
const pkgContent = await Bun.file(join(stackPath, "package.json")).text();
|
|
115
|
-
pkg = JSON.parse(pkgContent);
|
|
116
|
-
meta = pkg.stacks;
|
|
117
|
-
if (!meta?.name || meta.name !== registryEntry.name) {
|
|
118
|
-
log.error(`Registry source "${registryEntry.github}" does not declare stacks.name as "${registryEntry.name}"`);
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
} catch (error) {
|
|
122
|
-
log.error(`Failed to read stack metadata: ${error}`);
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
const lock = await readStackLock(projectRoot), packageName = pkg.name || registryEntry.package || name;
|
|
126
|
-
if (lock.stacks[packageName] && !force) {
|
|
127
|
-
log.warn(`Stack "${meta.name}" is already installed. Use --force to reinstall.`);
|
|
128
|
-
return lock.stacks[packageName];
|
|
129
|
-
}
|
|
130
|
-
const dirsToScan = meta.directories ?? STACK_DIRS;
|
|
131
|
-
if (dirsToScan.some((directory) => !isSafeStackDirectory(directory))) {
|
|
132
|
-
log.error(`Stack "${meta.name}" declares an unsafe project directory`);
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
const allFiles = [];
|
|
136
|
-
try {
|
|
137
|
-
for (const dir of dirsToScan) {
|
|
138
|
-
const dirPath = join(stackPath, dir);
|
|
139
|
-
if (fs.existsSync(dirPath))
|
|
140
|
-
allFiles.push(...collectFiles(dirPath, stackPath));
|
|
141
|
-
}
|
|
142
|
-
} catch (error) {
|
|
143
|
-
log.error(error instanceof Error ? error.message : String(error));
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
if (allFiles.length === 0) {
|
|
147
|
-
log.warn(`Stack "${meta.name}" has no project files to install`);
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
if (verbose)
|
|
151
|
-
log.info(`Pulled ${registryEntry.github} and found ${allFiles.length} project file(s)`);
|
|
152
|
-
const copiedFiles = [], skippedFiles = [], checksums = {};
|
|
153
|
-
for (const relPath of allFiles) {
|
|
154
|
-
const src = join(stackPath, relPath), dest = join(projectRoot, relPath);
|
|
155
|
-
if (dryRun) {
|
|
156
|
-
if (fs.existsSync(dest)) {
|
|
157
|
-
log.info(`[dry-run] Would ${conflict}: ${relPath}`);
|
|
158
|
-
if (conflict === "skip")
|
|
159
|
-
skippedFiles.push(relPath);
|
|
160
|
-
else
|
|
161
|
-
copiedFiles.push(relPath);
|
|
162
|
-
} else {
|
|
163
|
-
log.info(`[dry-run] Would copy: ${relPath}`);
|
|
164
|
-
copiedFiles.push(relPath);
|
|
165
|
-
}
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
if (fs.existsSync(dest))
|
|
169
|
-
switch (conflict) {
|
|
170
|
-
case "skip":
|
|
171
|
-
if (verbose)
|
|
172
|
-
log.warn(`Skipping (file exists): ${relPath}`);
|
|
173
|
-
skippedFiles.push(relPath);
|
|
174
|
-
continue;
|
|
175
|
-
case "backup": {
|
|
176
|
-
const backupDir = stackBackupPath(projectRoot, meta.name), backupDest = join(backupDir, relPath), backupDestDir = dirname(backupDest);
|
|
177
|
-
if (!fs.existsSync(backupDestDir))
|
|
178
|
-
await createFolder(backupDestDir);
|
|
179
|
-
copyFile(dest, backupDest);
|
|
180
|
-
if (verbose)
|
|
181
|
-
log.info(`Backed up: ${relPath}`);
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
case "overwrite":
|
|
185
|
-
if (verbose)
|
|
186
|
-
log.warn(`Overwriting: ${relPath}`);
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
const destDir = dirname(dest);
|
|
190
|
-
if (!fs.existsSync(destDir))
|
|
191
|
-
await createFolder(destDir);
|
|
192
|
-
copyFile(src, dest);
|
|
193
|
-
copiedFiles.push(relPath);
|
|
194
|
-
checksums[relPath] = fileChecksum(dest);
|
|
195
|
-
if (verbose)
|
|
196
|
-
log.info(`Copied: ${relPath}`);
|
|
197
|
-
}
|
|
198
|
-
const entry = {
|
|
199
|
-
packageName,
|
|
200
|
-
name: meta.name,
|
|
201
|
-
version: pkg.version || "0.0.0",
|
|
202
|
-
installedAt: new Date().toISOString(),
|
|
203
|
-
files: copiedFiles,
|
|
204
|
-
checksums,
|
|
205
|
-
source: registryEntry.github,
|
|
206
|
-
skipped: skippedFiles,
|
|
207
|
-
conflictStrategy: conflict
|
|
208
|
-
};
|
|
209
|
-
if (dryRun) {
|
|
210
|
-
log.info(`[dry-run] Would install ${copiedFiles.length} file(s), skip ${skippedFiles.length} file(s)`);
|
|
211
|
-
return entry;
|
|
212
|
-
}
|
|
213
|
-
lock.stacks[packageName] = entry;
|
|
214
|
-
await writeStackLock(projectRoot, lock);
|
|
215
|
-
log.success(`Installed stack "${meta.name}" from ${registryEntry.github} (${copiedFiles.length} file(s) copied, ${skippedFiles.length} skipped)`);
|
|
216
|
-
return entry;
|
|
217
|
-
} finally {
|
|
218
|
-
checkout.cleanup();
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
export async function uninstallStack(options) {
|
|
222
|
-
const { name, force = !1, verbose = !1 } = options, projectRoot = resolveProjectRoot(options.project);
|
|
223
|
-
log.info(`Uninstalling stack "${name}"...`);
|
|
224
|
-
const lock = await readStackLock(projectRoot);
|
|
225
|
-
let entryKey = null, entry = null;
|
|
226
|
-
for (const [key, value] of Object.entries(lock.stacks))
|
|
227
|
-
if (value.name === name || key === name) {
|
|
228
|
-
entryKey = key;
|
|
229
|
-
entry = value;
|
|
230
|
-
break;
|
|
231
|
-
}
|
|
232
|
-
if (!entry || !entryKey) {
|
|
233
|
-
log.error(`Stack "${name}" is not installed`);
|
|
234
|
-
return !1;
|
|
235
|
-
}
|
|
236
|
-
let removedCount = 0;
|
|
237
|
-
const remainingFiles = [];
|
|
238
|
-
for (const relPath of entry.files) {
|
|
239
|
-
const filePath = join(projectRoot, relPath);
|
|
240
|
-
if (!fs.existsSync(filePath)) {
|
|
241
|
-
if (verbose)
|
|
242
|
-
log.info(`Already removed: ${relPath}`);
|
|
243
|
-
continue;
|
|
244
|
-
}
|
|
245
|
-
if (!force) {
|
|
246
|
-
const installedChecksum = entry.checksums?.[relPath];
|
|
247
|
-
if (!installedChecksum || fileChecksum(filePath) !== installedChecksum) {
|
|
248
|
-
log.warn(`Skipping modified file: ${relPath} (use --force to remove)`);
|
|
249
|
-
remainingFiles.push(relPath);
|
|
250
|
-
continue;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
await deleteFile(filePath);
|
|
254
|
-
removedCount++;
|
|
255
|
-
if (verbose)
|
|
256
|
-
log.info(`Removed: ${relPath}`);
|
|
257
|
-
}
|
|
258
|
-
if (remainingFiles.length > 0) {
|
|
259
|
-
entry.files = remainingFiles;
|
|
260
|
-
entry.checksums = Object.fromEntries(remainingFiles.map((file) => [file, entry.checksums?.[file]]).filter((item) => typeof item[1] === "string"));
|
|
261
|
-
lock.stacks[entryKey] = entry;
|
|
262
|
-
await writeStackLock(projectRoot, lock);
|
|
263
|
-
log.warn(`Stack "${entry.name}" is still tracked because ${remainingFiles.length} modified file(s) remain`);
|
|
264
|
-
return !1;
|
|
265
|
-
}
|
|
266
|
-
const backupDir = stackBackupPath(projectRoot, entry.name);
|
|
267
|
-
if (fs.existsSync(backupDir) && doesFolderExist(backupDir)) {
|
|
268
|
-
const backupFiles = collectFiles(backupDir, backupDir);
|
|
269
|
-
for (const relPath of backupFiles) {
|
|
270
|
-
const backupSrc = join(backupDir, relPath), dest = join(projectRoot, relPath), destDir = dirname(dest);
|
|
271
|
-
if (!fs.existsSync(destDir))
|
|
272
|
-
await createFolder(destDir);
|
|
273
|
-
copyFile(backupSrc, dest);
|
|
274
|
-
if (verbose)
|
|
275
|
-
log.info(`Restored from backup: ${relPath}`);
|
|
276
|
-
}
|
|
277
|
-
fs.rmSync(backupDir, { recursive: !0, force: !0 });
|
|
278
|
-
}
|
|
279
|
-
for (const dir of STACK_DIRS) {
|
|
280
|
-
const dirPath = join(projectRoot, dir);
|
|
281
|
-
if (fs.existsSync(dirPath))
|
|
282
|
-
await deleteEmptyFolders(dirPath);
|
|
283
|
-
}
|
|
284
|
-
delete lock.stacks[entryKey];
|
|
285
|
-
await writeStackLock(projectRoot, lock);
|
|
286
|
-
log.success(`Uninstalled stack "${entry.name}" (${removedCount} file(s) removed)`);
|
|
287
|
-
return !0;
|
|
288
|
-
}
|
|
289
|
-
export async function listStacks(project) {
|
|
290
|
-
const entries = [], projectRoot = resolveProjectRoot(project), lock = await readStackLock(projectRoot);
|
|
291
|
-
for (const candidate of registry) {
|
|
292
|
-
if (typeof candidate === "string")
|
|
293
|
-
continue;
|
|
294
|
-
const packageName = candidate.package || candidate.name, lockEntry = lock.stacks[packageName];
|
|
295
|
-
entries.push({
|
|
296
|
-
name: candidate.name,
|
|
297
|
-
packageName,
|
|
298
|
-
version: lockEntry?.version || "latest",
|
|
299
|
-
description: candidate.description,
|
|
300
|
-
installed: Boolean(lockEntry),
|
|
301
|
-
installedAt: lockEntry?.installedAt,
|
|
302
|
-
fileCount: lockEntry?.files.length
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
for (const [packageName, entry] of Object.entries(lock.stacks))
|
|
306
|
-
if (!entries.some((e) => e.packageName === packageName))
|
|
307
|
-
entries.push({
|
|
308
|
-
name: entry.name,
|
|
309
|
-
packageName,
|
|
310
|
-
version: entry.version,
|
|
311
|
-
installed: !0,
|
|
312
|
-
installedAt: entry.installedAt,
|
|
313
|
-
fileCount: entry.files.length
|
|
314
|
-
});
|
|
315
|
-
return entries;
|
|
316
|
-
}
|
|
1
|
+
import{mkdtempSync,rmSync}from"node:fs";import{tmpdir}from"node:os";import{dirname,isAbsolute,join,relative,resolve}from"node:path";import process from"node:process";import{log}from"@stacksjs/logging";import{registry}from"@stacksjs/registry";import{copyFile,createFolder,deleteFile,deleteEmptyFolders,doesFolderExist,fs}from"@stacksjs/storage";const STACK_DIRS=["app","config","database","resources","routes","public","locales","docs"];function stackLockPath(projectRoot){return join(projectRoot,"storage","framework","stacks.lock.json")}function stackBackupPath(projectRoot,stackName){return join(projectRoot,"storage","framework","stacks","backups",stackName)}async function readStackLock(projectRoot){const lockPath=stackLockPath(projectRoot);try{if(fs.existsSync(lockPath)){const content=await Bun.file(lockPath).text();return JSON.parse(content)}}catch{}return{version:1,generatedAt:new Date().toISOString(),stacks:{}}}async function writeStackLock(projectRoot,lock){const lockPath=stackLockPath(projectRoot),lockDir=dirname(lockPath);if(!fs.existsSync(lockDir))await createFolder(lockDir);lock.generatedAt=new Date().toISOString();await Bun.write(lockPath,JSON.stringify(lock,null,2))}function resolveProjectRoot(project){return resolve(project||process.cwd())}function resolveRegistryEntry(name){const entry=registry.find((candidate)=>{if(typeof candidate==="string")return candidate===name;return candidate.name===name||candidate.package===name});if(!entry||typeof entry==="string")return null;if(!entry.github)return null;return{name:entry.name,github:entry.github,package:entry.package}}async function checkoutRegistryStack(github){const tempRoot=mkdtempSync(join(tmpdir(),"stacks-stack-")),checkoutPath=join(tempRoot,"source"),source=`https://github.com/${github}.git`;if(await Bun.spawn(["git","clone","--depth","1","--quiet",source,checkoutPath],{stdout:"inherit",stderr:"inherit"}).exited!==0){rmSync(tempRoot,{recursive:!0,force:!0});throw Error(`Could not pull ${source}`)}return{path:checkoutPath,cleanup:()=>rmSync(tempRoot,{recursive:!0,force:!0})}}function isSafeStackDirectory(directory){return directory.length>0&&!isAbsolute(directory)&&!directory.includes("..")&&!directory.includes("\\")}function fileChecksum(path){return new Bun.CryptoHasher("sha256").update(fs.readFileSync(path)).digest("hex")}function collectFiles(dir,baseDir){const files=[];if(!fs.existsSync(dir))return files;const entries=fs.readdirSync(dir,{withFileTypes:!0});for(const entry of entries){const fullPath=join(dir,entry.name);if(entry.isDirectory())files.push(...collectFiles(fullPath,baseDir));else if(entry.isSymbolicLink())throw Error(`Stack contains an unsupported symbolic link: ${relative(baseDir,fullPath)}`);else{const relPath=relative(baseDir,fullPath);if(!isSafeStackDirectory(relPath))throw Error(`Stack contains an unsafe path: ${relPath}`);files.push(relPath)}}return files}export async function installStack(options){const{name,force=!1,dryRun=!1,verbose=!1}=options,conflict=force?"overwrite":options.conflict??"skip",projectRoot=resolveProjectRoot(options.project);log.info(`Installing stack "${name}"...`);if(!fs.existsSync(join(projectRoot,"package.json"))){log.error(`No Stacks project found at "${projectRoot}"`);return null}const registryEntry=resolveRegistryEntry(name);if(!registryEntry){log.error(`Stack "${name}" is not in the Stacks registry. Run "buddy stack:list" to see available stacks.`);return null}let checkout;try{checkout=await checkoutRegistryStack(registryEntry.github)}catch(error){log.error(error instanceof Error?error.message:String(error));return null}try{const stackPath=checkout.path;let pkg,meta;try{const pkgContent=await Bun.file(join(stackPath,"package.json")).text();pkg=JSON.parse(pkgContent);meta=pkg.stacks;if(!meta?.name||meta.name!==registryEntry.name){log.error(`Registry source "${registryEntry.github}" does not declare stacks.name as "${registryEntry.name}"`);return null}}catch(error){log.error(`Failed to read stack metadata: ${error}`);return null}const lock=await readStackLock(projectRoot),packageName=pkg.name||registryEntry.package||name;if(lock.stacks[packageName]&&!force){log.warn(`Stack "${meta.name}" is already installed. Use --force to reinstall.`);return lock.stacks[packageName]}const dirsToScan=meta.directories??STACK_DIRS;if(dirsToScan.some((directory)=>!isSafeStackDirectory(directory))){log.error(`Stack "${meta.name}" declares an unsafe project directory`);return null}const allFiles=[];try{for(const dir of dirsToScan){const dirPath=join(stackPath,dir);if(fs.existsSync(dirPath))allFiles.push(...collectFiles(dirPath,stackPath))}}catch(error){log.error(error instanceof Error?error.message:String(error));return null}if(allFiles.length===0){log.warn(`Stack "${meta.name}" has no project files to install`);return null}if(verbose)log.info(`Pulled ${registryEntry.github} and found ${allFiles.length} project file(s)`);const copiedFiles=[],skippedFiles=[],checksums={};for(const relPath of allFiles){const src=join(stackPath,relPath),dest=join(projectRoot,relPath);if(dryRun){if(fs.existsSync(dest)){log.info(`[dry-run] Would ${conflict}: ${relPath}`);if(conflict==="skip")skippedFiles.push(relPath);else copiedFiles.push(relPath)}else{log.info(`[dry-run] Would copy: ${relPath}`);copiedFiles.push(relPath)}continue}if(fs.existsSync(dest))switch(conflict){case"skip":if(verbose)log.warn(`Skipping (file exists): ${relPath}`);skippedFiles.push(relPath);continue;case"backup":{const backupDir=stackBackupPath(projectRoot,meta.name),backupDest=join(backupDir,relPath),backupDestDir=dirname(backupDest);if(!fs.existsSync(backupDestDir))await createFolder(backupDestDir);copyFile(dest,backupDest);if(verbose)log.info(`Backed up: ${relPath}`);break}case"overwrite":if(verbose)log.warn(`Overwriting: ${relPath}`);break}const destDir=dirname(dest);if(!fs.existsSync(destDir))await createFolder(destDir);copyFile(src,dest);copiedFiles.push(relPath);checksums[relPath]=fileChecksum(dest);if(verbose)log.info(`Copied: ${relPath}`)}const entry={packageName,name:meta.name,version:pkg.version||"0.0.0",installedAt:new Date().toISOString(),files:copiedFiles,checksums,source:registryEntry.github,skipped:skippedFiles,conflictStrategy:conflict};if(dryRun){log.info(`[dry-run] Would install ${copiedFiles.length} file(s), skip ${skippedFiles.length} file(s)`);return entry}lock.stacks[packageName]=entry;await writeStackLock(projectRoot,lock);log.success(`Installed stack "${meta.name}" from ${registryEntry.github} (${copiedFiles.length} file(s) copied, ${skippedFiles.length} skipped)`);return entry}finally{checkout.cleanup()}}export async function uninstallStack(options){const{name,force=!1,verbose=!1}=options,projectRoot=resolveProjectRoot(options.project);log.info(`Uninstalling stack "${name}"...`);const lock=await readStackLock(projectRoot);let entryKey=null,entry=null;for(const[key,value]of Object.entries(lock.stacks))if(value.name===name||key===name){entryKey=key;entry=value;break}if(!entry||!entryKey){log.error(`Stack "${name}" is not installed`);return!1}let removedCount=0;const remainingFiles=[];for(const relPath of entry.files){const filePath=join(projectRoot,relPath);if(!fs.existsSync(filePath)){if(verbose)log.info(`Already removed: ${relPath}`);continue}if(!force){const installedChecksum=entry.checksums?.[relPath];if(!installedChecksum||fileChecksum(filePath)!==installedChecksum){log.warn(`Skipping modified file: ${relPath} (use --force to remove)`);remainingFiles.push(relPath);continue}}await deleteFile(filePath);removedCount++;if(verbose)log.info(`Removed: ${relPath}`)}if(remainingFiles.length>0){entry.files=remainingFiles;entry.checksums=Object.fromEntries(remainingFiles.map((file)=>[file,entry.checksums?.[file]]).filter((item)=>typeof item[1]==="string"));lock.stacks[entryKey]=entry;await writeStackLock(projectRoot,lock);log.warn(`Stack "${entry.name}" is still tracked because ${remainingFiles.length} modified file(s) remain`);return!1}const backupDir=stackBackupPath(projectRoot,entry.name);if(fs.existsSync(backupDir)&&doesFolderExist(backupDir)){const backupFiles=collectFiles(backupDir,backupDir);for(const relPath of backupFiles){const backupSrc=join(backupDir,relPath),dest=join(projectRoot,relPath),destDir=dirname(dest);if(!fs.existsSync(destDir))await createFolder(destDir);copyFile(backupSrc,dest);if(verbose)log.info(`Restored from backup: ${relPath}`)}fs.rmSync(backupDir,{recursive:!0,force:!0})}for(const dir of STACK_DIRS){const dirPath=join(projectRoot,dir);if(fs.existsSync(dirPath))await deleteEmptyFolders(dirPath)}delete lock.stacks[entryKey];await writeStackLock(projectRoot,lock);log.success(`Uninstalled stack "${entry.name}" (${removedCount} file(s) removed)`);return!0}export async function listStacks(project){const entries=[],projectRoot=resolveProjectRoot(project),lock=await readStackLock(projectRoot);for(const candidate of registry){if(typeof candidate==="string")continue;const packageName=candidate.package||candidate.name,lockEntry=lock.stacks[packageName];entries.push({name:candidate.name,packageName,version:lockEntry?.version||"latest",description:candidate.description,installed:Boolean(lockEntry),installedAt:lockEntry?.installedAt,fileCount:lockEntry?.files.length})}for(const[packageName,entry]of Object.entries(lock.stacks))if(!entries.some((e)=>e.packageName===packageName))entries.push({name:entry.name,packageName,version:entry.version,installed:!0,installedAt:entry.installedAt,fileCount:entry.files.length});return entries}
|
package/dist/templates.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export const CODE_TEMPLATES
|
|
2
|
-
action: `import { Action } from '@stacksjs/actions'
|
|
1
|
+
export const CODE_TEMPLATES={action:`import { Action } from '@stacksjs/actions'
|
|
3
2
|
|
|
4
3
|
export default new Action({
|
|
5
4
|
name: '{0}',
|
|
@@ -8,8 +7,7 @@ export default new Action({
|
|
|
8
7
|
handle() {
|
|
9
8
|
return 'Hello World action'
|
|
10
9
|
},
|
|
11
|
-
})`,
|
|
12
|
-
actionWithValidation: `import { Action } from '@stacksjs/actions'
|
|
10
|
+
})`,actionWithValidation:`import { Action } from '@stacksjs/actions'
|
|
13
11
|
import { schema, validate } from '@stacksjs/validation'
|
|
14
12
|
|
|
15
13
|
export default new Action({
|
|
@@ -26,8 +24,7 @@ export default new Action({
|
|
|
26
24
|
|
|
27
25
|
return { ok: true, data }
|
|
28
26
|
},
|
|
29
|
-
})`,
|
|
30
|
-
actionWithAuth: `import { Action } from '@stacksjs/actions'
|
|
27
|
+
})`,actionWithAuth:`import { Action } from '@stacksjs/actions'
|
|
31
28
|
|
|
32
29
|
export default new Action({
|
|
33
30
|
name: '{0}',
|
|
@@ -41,8 +38,7 @@ export default new Action({
|
|
|
41
38
|
|
|
42
39
|
return { ok: true, userId: user.id }
|
|
43
40
|
},
|
|
44
|
-
})`,
|
|
45
|
-
actionWithBoth: `import { Action } from '@stacksjs/actions'
|
|
41
|
+
})`,actionWithBoth:`import { Action } from '@stacksjs/actions'
|
|
46
42
|
import { schema, validate } from '@stacksjs/validation'
|
|
47
43
|
|
|
48
44
|
export default new Action({
|
|
@@ -61,8 +57,7 @@ export default new Action({
|
|
|
61
57
|
|
|
62
58
|
return { ok: true, userId: user.id, data }
|
|
63
59
|
},
|
|
64
|
-
})`,
|
|
65
|
-
component: `<script server>
|
|
60
|
+
})`,component:`<script server>
|
|
66
61
|
interface ComponentProps {
|
|
67
62
|
message?: string
|
|
68
63
|
}
|
|
@@ -72,8 +67,7 @@ const { message = 'Hello World component created' } = defineProps<ComponentProps
|
|
|
72
67
|
|
|
73
68
|
<template>
|
|
74
69
|
<div>{{ message }}</div>
|
|
75
|
-
</template>`,
|
|
76
|
-
page: `<script server>
|
|
70
|
+
</template>`,page:`<script server>
|
|
77
71
|
const heading = 'Hello World page created'
|
|
78
72
|
</script>
|
|
79
73
|
|
|
@@ -82,13 +76,10 @@ const heading = 'Hello World page created'
|
|
|
82
76
|
<h1>{{ heading }}</h1>
|
|
83
77
|
<p>Visit /{0}</p>
|
|
84
78
|
</div>
|
|
85
|
-
</template>`,
|
|
86
|
-
function: `export function {0}(): void {
|
|
79
|
+
</template>`,function:`export function {0}(): void {
|
|
87
80
|
// Add function logic here.
|
|
88
|
-
}`,
|
|
89
|
-
|
|
90
|
-
text: Copy`,
|
|
91
|
-
notification: `import type { {0} } from '@stacksjs/types'
|
|
81
|
+
}`,language:`button:
|
|
82
|
+
text: Copy`,notification:`import type { {0} } from '@stacksjs/types'
|
|
92
83
|
|
|
93
84
|
function content(): string {
|
|
94
85
|
return 'example'
|
|
@@ -98,8 +89,7 @@ function send(): {0} {
|
|
|
98
89
|
return {
|
|
99
90
|
content: content(),
|
|
100
91
|
}
|
|
101
|
-
}`,
|
|
102
|
-
mail: `import { Mailable } from '@stacksjs/email'
|
|
92
|
+
}`,mail:`import { Mailable } from '@stacksjs/email'
|
|
103
93
|
|
|
104
94
|
/**
|
|
105
95
|
* Props passed into the {0} email. Add the fields your template
|
|
@@ -138,8 +128,7 @@ export class {0} extends Mailable<{0}Props> {
|
|
|
138
128
|
userName: this.props.userName ?? 'there',
|
|
139
129
|
})
|
|
140
130
|
}
|
|
141
|
-
}`,
|
|
142
|
-
mailTemplate: `<script server>
|
|
131
|
+
}`,mailTemplate:`<script server>
|
|
143
132
|
// Generated by \`buddy make:mail {0}\`. Edit freely. \`props\` is the
|
|
144
133
|
// object passed by the Mailable's \`build()\`.
|
|
145
134
|
const appName = props.appName || 'Stacks'
|
|
@@ -199,8 +188,7 @@ const year = props.year || new Date().getFullYear()
|
|
|
199
188
|
</tr>
|
|
200
189
|
</table>
|
|
201
190
|
</body>
|
|
202
|
-
</html>`,
|
|
203
|
-
middleware: `import type { Request } from '@stacksjs/router'
|
|
191
|
+
</html>`,middleware:`import type { Request } from '@stacksjs/router'
|
|
204
192
|
import { Middleware } from '@stacksjs/router'
|
|
205
193
|
|
|
206
194
|
export default new Middleware({
|
|
@@ -209,8 +197,7 @@ export default new Middleware({
|
|
|
209
197
|
async handle(request: Request) {
|
|
210
198
|
// Your middleware logic here
|
|
211
199
|
},
|
|
212
|
-
})`,
|
|
213
|
-
model: `import { defineModel } from '@stacksjs/orm'
|
|
200
|
+
})`,model:`import { defineModel } from '@stacksjs/orm'
|
|
214
201
|
import { schema } from '@stacksjs/validation'
|
|
215
202
|
|
|
216
203
|
export default defineModel({
|
|
@@ -230,12 +217,10 @@ export default defineModel({
|
|
|
230
217
|
attributes: {
|
|
231
218
|
// your attributes here
|
|
232
219
|
},
|
|
233
|
-
} as const)`,
|
|
234
|
-
migration: `CREATE TABLE {0} (
|
|
220
|
+
} as const)`,migration:`CREATE TABLE {0} (
|
|
235
221
|
{1}
|
|
236
222
|
);
|
|
237
|
-
`,
|
|
238
|
-
stackPackageJson: `{
|
|
223
|
+
`,stackPackageJson:`{
|
|
239
224
|
"name": "{0}",
|
|
240
225
|
"version": "0.0.1",
|
|
241
226
|
"type": "module",
|
|
@@ -243,8 +228,7 @@ export default defineModel({
|
|
|
243
228
|
"name": "{1}",
|
|
244
229
|
"description": "A Stacks extension"
|
|
245
230
|
}
|
|
246
|
-
}`,
|
|
247
|
-
job: `import { Job } from '@stacksjs/jobs'
|
|
231
|
+
}`,job:`import { Job } from '@stacksjs/jobs'
|
|
248
232
|
|
|
249
233
|
export default new Job({
|
|
250
234
|
name: '{0}',
|
|
@@ -254,8 +238,7 @@ export default new Job({
|
|
|
254
238
|
// Your job logic here
|
|
255
239
|
console.log('Job executed')
|
|
256
240
|
},
|
|
257
|
-
})`,
|
|
258
|
-
event: `import { Event } from '@stacksjs/events'
|
|
241
|
+
})`,event:`import { Event } from '@stacksjs/events'
|
|
259
242
|
|
|
260
243
|
export default new Event({
|
|
261
244
|
name: '{0}',
|
|
@@ -265,8 +248,7 @@ export default new Event({
|
|
|
265
248
|
// Your event handler logic here
|
|
266
249
|
console.log('Event handled:', data)
|
|
267
250
|
},
|
|
268
|
-
})`,
|
|
269
|
-
listener: `import { Listener } from '@stacksjs/events'
|
|
251
|
+
})`,listener:`import { Listener } from '@stacksjs/events'
|
|
270
252
|
|
|
271
253
|
export default new Listener({
|
|
272
254
|
name: '{0}',
|
|
@@ -276,8 +258,7 @@ export default new Listener({
|
|
|
276
258
|
// Your listener logic here
|
|
277
259
|
console.log('Listener triggered:', data)
|
|
278
260
|
},
|
|
279
|
-
})`,
|
|
280
|
-
command: `import { Command } from '@stacksjs/cli'
|
|
261
|
+
})`,command:`import { Command } from '@stacksjs/cli'
|
|
281
262
|
|
|
282
263
|
export default new Command({
|
|
283
264
|
name: '{0}',
|
|
@@ -287,5 +268,4 @@ export default new Command({
|
|
|
287
268
|
// Your command logic here
|
|
288
269
|
console.log('Command executed')
|
|
289
270
|
},
|
|
290
|
-
})`
|
|
291
|
-
};
|
|
271
|
+
})`};
|
package/dist/test/feature.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
await runTestSuites(["feature"]);
|
|
1
|
+
import{runTestSuites}from"./runner";await runTestSuites(["feature"]);
|
package/dist/test/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
await runTestSuites([""], 30000);
|
|
1
|
+
import{runTestSuites}from"./runner";await runTestSuites([""],30000);
|
package/dist/test/runner.js
CHANGED
|
@@ -1,38 +1 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
import { existsSync, realpathSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { log } from "@stacksjs/cli";
|
|
5
|
-
import { projectPath } from "@stacksjs/path";
|
|
6
|
-
const testFilePattern = "**/*.{test,spec}.{js,jsx,ts,tsx,mjs,mts,cjs,cts}";
|
|
7
|
-
export function resolveTestSuiteFilters(project, suites) {
|
|
8
|
-
const visitedDirectories = new Set;
|
|
9
|
-
return suites.flatMap((suite) => {
|
|
10
|
-
const suiteDirectory = join(project, "tests", suite);
|
|
11
|
-
if (!existsSync(suiteDirectory))
|
|
12
|
-
return [];
|
|
13
|
-
const canonicalDirectory = realpathSync(suiteDirectory);
|
|
14
|
-
if (visitedDirectories.has(canonicalDirectory))
|
|
15
|
-
return [];
|
|
16
|
-
visitedDirectories.add(canonicalDirectory);
|
|
17
|
-
return [...new Bun.Glob(testFilePattern).scanSync({ cwd: suiteDirectory, onlyFiles: !0 })].map((file) => suite ? `./tests/${suite}/${file}` : `./tests/${file}`);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
export async function runTestSuites(suites, timeout) {
|
|
21
|
-
const project = projectPath(), filters = resolveTestSuiteFilters(project, suites);
|
|
22
|
-
if (filters.length === 0) {
|
|
23
|
-
log.info("No matching tests found.");
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const args = ["bun", "test"];
|
|
27
|
-
if (timeout)
|
|
28
|
-
args.push("--timeout", String(timeout));
|
|
29
|
-
args.push(...filters);
|
|
30
|
-
const exitCode = await Bun.spawn(args, {
|
|
31
|
-
cwd: project,
|
|
32
|
-
stdio: ["inherit", "inherit", "inherit"]
|
|
33
|
-
}).exited;
|
|
34
|
-
if (exitCode !== 0) {
|
|
35
|
-
log.error("Tests failed");
|
|
36
|
-
process.exit(exitCode ?? 1);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
import process from"node:process";import{existsSync,realpathSync}from"node:fs";import{join}from"node:path";import{log}from"@stacksjs/cli";import{projectPath}from"@stacksjs/path";const testFilePattern="**/*.{test,spec}.{js,jsx,ts,tsx,mjs,mts,cjs,cts}";export function resolveTestSuiteFilters(project,suites){const visitedDirectories=new Set;return suites.flatMap((suite)=>{const suiteDirectory=join(project,"tests",suite);if(!existsSync(suiteDirectory))return[];const canonicalDirectory=realpathSync(suiteDirectory);if(visitedDirectories.has(canonicalDirectory))return[];visitedDirectories.add(canonicalDirectory);return[...new Bun.Glob(testFilePattern).scanSync({cwd:suiteDirectory,onlyFiles:!0})].map((file)=>suite?`./tests/${suite}/${file}`:`./tests/${file}`)})}export async function runTestSuites(suites,timeout){const project=projectPath(),filters=resolveTestSuiteFilters(project,suites);if(filters.length===0){log.info("No matching tests found.");return}const args=["bun","test"];if(timeout)args.push("--timeout",String(timeout));args.push(...filters);const exitCode=await Bun.spawn(args,{cwd:project,stdio:["inherit","inherit","inherit"]}).exited;if(exitCode!==0){log.error("Tests failed");process.exit(exitCode??1)}}
|
package/dist/test/runner.test.js
CHANGED
|
@@ -1,29 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { resolveTestSuiteFilters } from "./runner";
|
|
6
|
-
let project;
|
|
7
|
-
beforeAll(() => {
|
|
8
|
-
project = mkdtempSync(join(tmpdir(), "stacks-test-suites-"));
|
|
9
|
-
mkdirSync(join(project, "tests", "Browser"), { recursive: !0 });
|
|
10
|
-
mkdirSync(join(project, "tests", "browser"), { recursive: !0 });
|
|
11
|
-
mkdirSync(join(project, "tests", "unit"), { recursive: !0 });
|
|
12
|
-
writeFileSync(join(project, "tests", "Browser", "composer.test.ts"), "");
|
|
13
|
-
writeFileSync(join(project, "tests", "browser", "timeline.spec.ts"), "");
|
|
14
|
-
writeFileSync(join(project, "tests", "unit", "ignored.test.ts"), "");
|
|
15
|
-
});
|
|
16
|
-
afterAll(() => {
|
|
17
|
-
rmSync(project, { recursive: !0, force: !0 });
|
|
18
|
-
});
|
|
19
|
-
describe("test suite discovery", () => {
|
|
20
|
-
it("discovers supported browser suite names without leaking other tests", () => {
|
|
21
|
-
expect(resolveTestSuiteFilters(project, ["Browser", "browser", "ui"]).sort()).toEqual([
|
|
22
|
-
"./tests/Browser/composer.test.js",
|
|
23
|
-
"./tests/Browser/timeline.spec.js"
|
|
24
|
-
]);
|
|
25
|
-
});
|
|
26
|
-
it("returns no filters when a project has no matching UI suite", () => {
|
|
27
|
-
expect(resolveTestSuiteFilters(project, ["ui"])).toEqual([]);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
1
|
+
import{afterAll,beforeAll,describe,expect,it}from"bun:test";import{mkdirSync,mkdtempSync,rmSync,writeFileSync}from"node:fs";import{tmpdir}from"node:os";import{join}from"node:path";import{resolveTestSuiteFilters}from"./runner";let project;beforeAll(()=>{project=mkdtempSync(join(tmpdir(),"stacks-test-suites-"));mkdirSync(join(project,"tests","Browser"),{recursive:!0});mkdirSync(join(project,"tests","browser"),{recursive:!0});mkdirSync(join(project,"tests","unit"),{recursive:!0});writeFileSync(join(project,"tests","Browser","composer.test.ts"),"");writeFileSync(join(project,"tests","browser","timeline.spec.ts"),"");writeFileSync(join(project,"tests","unit","ignored.test.ts"),"")});afterAll(()=>{rmSync(project,{recursive:!0,force:!0})});describe("test suite discovery",()=>{it("discovers supported browser suite names without leaking other tests",()=>{expect(resolveTestSuiteFilters(project,["Browser","browser","ui"]).sort()).toEqual(["./tests/Browser/composer.test.js","./tests/Browser/timeline.spec.js"])});it("returns no filters when a project has no matching UI suite",()=>{expect(resolveTestSuiteFilters(project,["ui"])).toEqual([])})});
|
package/dist/test/ui.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
await runTestSuites(["Browser", "browser", "ui"]);
|
|
1
|
+
import{runTestSuites}from"./runner";await runTestSuites(["Browser","browser","ui"]);
|
package/dist/test/unit.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
await runTestSuites(["unit"]);
|
|
1
|
+
import{runTestSuites}from"./runner";await runTestSuites(["unit"]);
|
package/dist/typecheck.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { NpmScript } from "@stacksjs/enums";
|
|
3
|
-
import { projectPath } from "@stacksjs/path";
|
|
4
|
-
await runCommands([NpmScript.TestTypes], { cwd: projectPath() });
|
|
1
|
+
import{runCommands}from"@stacksjs/cli";import{NpmScript}from"@stacksjs/enums";import{projectPath}from"@stacksjs/path";await runCommands([NpmScript.TestTypes],{cwd:projectPath()});
|
package/dist/types.js
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
import { NpmScript } from "@stacksjs/enums";
|
|
3
|
-
import { log } from "@stacksjs/logging";
|
|
4
|
-
import { ExitCode } from "@stacksjs/types";
|
|
5
|
-
import { runNpmScript } from "@stacksjs/utils";
|
|
6
|
-
export async function invoke(options) {
|
|
7
|
-
const results = await runNpmScript(NpmScript.TypesFix, options);
|
|
8
|
-
if (results.isErr) {
|
|
9
|
-
log.error("There was an error fixing your types.", results.error);
|
|
10
|
-
process.exit(ExitCode.FatalError);
|
|
11
|
-
}
|
|
12
|
-
log.success("Types are set");
|
|
13
|
-
}
|
|
14
|
-
export async function types(options) {
|
|
15
|
-
return await invoke(options);
|
|
16
|
-
}
|
|
1
|
+
import process from"node:process";import{NpmScript}from"@stacksjs/enums";import{log}from"@stacksjs/logging";import{ExitCode}from"@stacksjs/types";import{runNpmScript}from"@stacksjs/utils";export async function invoke(options){const results=await runNpmScript(NpmScript.TypesFix,options);if(results.isErr){log.error("There was an error fixing your types.",results.error);process.exit(ExitCode.FatalError)}log.success("Types are set")}export async function types(options){return await invoke(options)}
|
package/dist/upgrade/binary.js
CHANGED
|
@@ -1,29 +1 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
import { runCommand } from "@stacksjs/cli";
|
|
3
|
-
import { log } from "@stacksjs/logging";
|
|
4
|
-
import { path } from "@stacksjs/path";
|
|
5
|
-
import { ExitCode } from "@stacksjs/types";
|
|
6
|
-
import { fs, storage } from "@stacksjs/storage";
|
|
7
|
-
const source = path.buddyPath("dist/stacks"), destination = path.homeDir(".stacks/bin/stacks"), destinationDir = path.homeDir(".stacks/bin/");
|
|
8
|
-
log.info("Upgrading `stacks`...");
|
|
9
|
-
const result = await runCommand("bun compile.ts", { cwd: path.buddyPath() });
|
|
10
|
-
if (result.isErr) {
|
|
11
|
-
log.error("There was an error compiling the binary", result.error);
|
|
12
|
-
process.exit(ExitCode.FatalError);
|
|
13
|
-
}
|
|
14
|
-
if (await storage.exists(source))
|
|
15
|
-
try {
|
|
16
|
-
log.info("Updating Binary...");
|
|
17
|
-
log.info(`Source: ${source}`);
|
|
18
|
-
log.info(`Destination: ${destination}`);
|
|
19
|
-
await fs.ensureDir(destinationDir);
|
|
20
|
-
await fs.move(source, destination, { overwrite: !0 });
|
|
21
|
-
log.success("Binary Latest Version Is Used");
|
|
22
|
-
} catch (err) {
|
|
23
|
-
log.error(err);
|
|
24
|
-
process.exit(ExitCode.FatalError);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
log.error(`Binary source not found: ${source}`);
|
|
28
|
-
process.exit(ExitCode.FatalError);
|
|
29
|
-
}
|
|
1
|
+
import process from"node:process";import{runCommand}from"@stacksjs/cli";import{log}from"@stacksjs/logging";import{path}from"@stacksjs/path";import{ExitCode}from"@stacksjs/types";import{fs,storage}from"@stacksjs/storage";const source=path.buddyPath("dist/stacks"),destination=path.homeDir(".stacks/bin/stacks"),destinationDir=path.homeDir(".stacks/bin/");log.info("Upgrading `stacks`...");const result=await runCommand("bun compile.ts",{cwd:path.buddyPath()});if(result.isErr){log.error("There was an error compiling the binary",result.error);process.exit(ExitCode.FatalError)}if(await storage.exists(source))try{log.info("Updating Binary...");log.info(`Source: ${source}`);log.info(`Destination: ${destination}`);await fs.ensureDir(destinationDir);await fs.move(source,destination,{overwrite:!0});log.success("Binary Latest Version Is Used")}catch(err){log.error(err);process.exit(ExitCode.FatalError)}else{log.error(`Binary source not found: ${source}`);process.exit(ExitCode.FatalError)}
|