kreftjs 0.0.2-beta → 0.0.4-beta
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/README.md +12 -12
- package/bin/add.js +14 -14
- package/bin/artisan-more.js +41 -41
- package/bin/artisan.js +41 -41
- package/bin/backend/command.js +1 -1
- package/bin/backend/factory.js +1 -1
- package/bin/backend/index.js +3 -3
- package/bin/backend/model.js +2 -2
- package/bin/backend/notifications.js +1 -1
- package/bin/backend/queue.js +2 -2
- package/bin/backend/schedule.js +2 -2
- package/bin/backend/seo-pages.js +1 -1
- package/bin/backend/storage.js +1 -1
- package/bin/backend/support.js +4 -4
- package/bin/backend/typescript.js +1 -1
- package/bin/build.js +11 -11
- package/bin/db-api.js +3 -3
- package/bin/db.js +1 -1
- package/bin/deps.js +6 -6
- package/bin/electron.js +12 -12
- package/bin/env.js +2 -2
- package/bin/guard.js +2 -2
- package/bin/kreftjs-config.js +1 -1
- package/bin/kreftjs.js +105 -109
- package/bin/layout.js +1 -1
- package/bin/no-auth.js +4 -4
- package/bin/prerender.js +4 -4
- package/bin/server-routes.js +2 -2
- package/bin/ssr.js +2 -2
- package/bin/terminal.js +1 -1
- package/bin/to-ts.js +1 -1
- package/bin/update.js +17 -17
- package/bin/urls-file.js +1 -1
- package/bin/vite.js +11 -11
- package/bin/win-spawn.js +39 -0
- package/docs/Docs.kreftjs +1 -1
- package/docs/README.md +140 -123
- package/kreftjs.d.ts +1 -1
- package/kreftjs.js +18 -18
- package/package.json +3 -4
- package/templates/app/README.md +20 -20
- package/templates/app/backend/database/migrations/0001_01_01_000000_create_users_table.js +1 -1
- package/templates/app/backend/database/migrations/0001_01_01_000002_create_jobs_table.js +1 -1
- package/templates/app/backend/database/seeders/DatabaseSeeder.js +1 -1
- package/templates/app/backend/routes/api.js +1 -1
- package/templates/app/backend/routes/console.js +2 -2
- package/templates/app/frontend/errors/ErrorMonitor.kreftjs +2 -2
- package/templates/app/frontend/index.html +1 -1
- package/templates/app/frontend/kreftjs.d.ts +1 -1
- package/templates/app/frontend/kreftjs.js +18 -18
- package/templates/app/frontend/pages/Dashboard.kreftjs +1 -1
- package/templates/app/frontend/pages/ErrorMonitor.kreftjs +1 -1
- package/templates/app/frontend/pages/Home.kreftjs +2 -2
- package/templates/errors/ErrorMonitor.kreftjs +1 -1
package/bin/update.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
2
|
+
* kreft update [packages...]
|
|
3
3
|
*
|
|
4
4
|
* Updates npm dependencies and/or Kreft runtime files in the current project:
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* kreft update Update all packages (npm update) and refresh kreftjs.js / kreftjs.d.ts
|
|
7
|
+
* kreft update <package...> Update specific npm package(s)
|
|
8
|
+
* kreft update --latest Upgrade dependencies to their latest versions
|
|
9
|
+
* kreft update --check Check for outdated packages without installing (npm outdated)
|
|
10
|
+
* kreft update --core Update only Kreft runtime files (kreftjs.js, kreftjs.d.ts, server.d.ts)
|
|
11
|
+
* kreft update --npm Update only npm packages
|
|
12
12
|
*/
|
|
13
13
|
const fs = require('fs');
|
|
14
14
|
const path = require('path');
|
|
15
|
-
const {
|
|
15
|
+
const { runSync } = require('./win-spawn.js');
|
|
16
16
|
const { layout } = require('./layout.js');
|
|
17
17
|
const pkg = require('../package.json');
|
|
18
18
|
|
|
@@ -180,7 +180,7 @@ function updateNpmPackages(project, pkgs, flags) {
|
|
|
180
180
|
|
|
181
181
|
if (flags.has('check')) {
|
|
182
182
|
console.log(` ${cyan('Checking for outdated packages (npm outdated):')}\n`);
|
|
183
|
-
const res =
|
|
183
|
+
const res = runSync(npmCmd, ['outdated'], { stdio: 'inherit', cwd: project });
|
|
184
184
|
if (res.status === 0) {
|
|
185
185
|
console.log(` ${green('All packages are up to date.')}`);
|
|
186
186
|
}
|
|
@@ -210,7 +210,7 @@ function updateNpmPackages(project, pkgs, flags) {
|
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
console.log(` ${dim('$ ' + npmCmd + ' ' + cmdArgs.join(' '))}\n`);
|
|
213
|
-
const result =
|
|
213
|
+
const result = runSync(npmCmd, cmdArgs, { stdio: 'inherit', cwd: project });
|
|
214
214
|
|
|
215
215
|
if (result.error) {
|
|
216
216
|
console.error(` ${red('Error running npm:')} ${result.error.message}`);
|
|
@@ -226,12 +226,12 @@ function updateNpmPackages(project, pkgs, flags) {
|
|
|
226
226
|
function printHelp() {
|
|
227
227
|
console.log(`
|
|
228
228
|
Usage:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
229
|
+
kreft update [package...] Update project packages and Kreft runtime files
|
|
230
|
+
kreft update Update all packages in package.json and refresh kreftjs.js
|
|
231
|
+
kreft update <name> Update a specific package (e.g. kreft update esbuild)
|
|
232
|
+
kreft update --latest Upgrade packages to their latest versions
|
|
233
|
+
kreft update --check Check for outdated packages (npm outdated)
|
|
234
|
+
kreft update --core Update only Kreft runtime files (kreftjs.js, kreftjs.d.ts, server.d.ts)
|
|
235
|
+
kreft update --npm Update only npm dependencies
|
|
236
236
|
`);
|
|
237
237
|
}
|
package/bin/urls-file.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* A list of page addresses from a file, for `
|
|
2
|
+
* A list of page addresses from a file, for `kreft build --prerender --urls urls.js` and `kreft sitemap --urls urls.js`.
|
|
3
3
|
*
|
|
4
4
|
* urls.json ["/posts/1", "/posts/2"] or [{ "path": "/posts/1", "lastmod": "2026-01-02" }]
|
|
5
5
|
* urls.txt one address per line (# starts a comment)
|
package/bin/vite.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* Vite.js Bundler & Dev Server Integration for Kreft
|
|
3
3
|
*
|
|
4
4
|
* Commands:
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* kreft vite:init Add Vite configuration and dependencies to an existing project (alias: kreft make:vite)
|
|
6
|
+
* kreft vite:dev Start ultra-fast Vite dev server with instant HMR and backend proxy (alias: kreft vite)
|
|
7
|
+
* kreft vite:build Build optimized static frontend with Rollup and code-splitting
|
|
8
|
+
* kreft vite:preview Preview production bundle locally using Vite
|
|
9
9
|
*
|
|
10
10
|
* CLI flag:
|
|
11
|
-
*
|
|
11
|
+
* kreft new my-app --vite
|
|
12
12
|
*/
|
|
13
13
|
const fs = require('fs');
|
|
14
14
|
const path = require('path');
|
|
@@ -80,10 +80,10 @@ function init(args = [], opts = {}) {
|
|
|
80
80
|
// Update package.json
|
|
81
81
|
const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf8'));
|
|
82
82
|
pkg.scripts = pkg.scripts || {};
|
|
83
|
-
pkg.scripts['vite'] = '
|
|
84
|
-
pkg.scripts['vite:dev'] = '
|
|
85
|
-
pkg.scripts['vite:build'] = '
|
|
86
|
-
pkg.scripts['vite:preview'] = '
|
|
83
|
+
pkg.scripts['vite'] = 'kreft vite';
|
|
84
|
+
pkg.scripts['vite:dev'] = 'kreft vite:dev';
|
|
85
|
+
pkg.scripts['vite:build'] = 'kreft vite:build';
|
|
86
|
+
pkg.scripts['vite:preview'] = 'kreft vite:preview';
|
|
87
87
|
|
|
88
88
|
pkg.devDependencies = pkg.devDependencies || {};
|
|
89
89
|
if (!pkg.devDependencies['vite']) {
|
|
@@ -99,8 +99,8 @@ function init(args = [], opts = {}) {
|
|
|
99
99
|
|
|
100
100
|
Next:
|
|
101
101
|
npm install (install vite)
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
kreft vite:dev (start ultra-fast Vite dev server with instant HMR)
|
|
103
|
+
kreft vite:build (build production bundle with Rollup)
|
|
104
104
|
`);
|
|
105
105
|
}
|
|
106
106
|
|
package/bin/win-spawn.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Starting npm and other .cmd programs on Windows.
|
|
3
|
+
*
|
|
4
|
+
* Since Node.js 20.12 (and 22) a .cmd or .bat file can only be started through a shell: spawn('npm.cmd') alone fails with
|
|
5
|
+
* "spawnSync npm.cmd EINVAL". These helpers do that on Windows and start the program directly everywhere else.
|
|
6
|
+
* With a shell, an argument could carry a second command (`pkg & calc`), so characters that mean something to cmd.exe are refused.
|
|
7
|
+
*/
|
|
8
|
+
const { spawn, spawnSync } = require('child_process');
|
|
9
|
+
|
|
10
|
+
const WIN = () => process.platform === 'win32';
|
|
11
|
+
const UNSAFE = /[;&|`$<>%!"\r\n]/;
|
|
12
|
+
const quote = (a) => (/[\s^()]/.test(a) ? `"${a}"` : a);
|
|
13
|
+
const isCmdFile = (f) => /\.(cmd|bat)$/i.test(f);
|
|
14
|
+
|
|
15
|
+
function prepare(cmd, args, options) {
|
|
16
|
+
if (!WIN() || !isCmdFile(cmd) && cmd !== 'npm' && cmd !== 'npx') return { cmd, args, options };
|
|
17
|
+
const list = args.map(String);
|
|
18
|
+
const bad = list.find((a) => UNSAFE.test(a));
|
|
19
|
+
if (bad) throw new Error(`The argument ${JSON.stringify(bad)} has a character that is not allowed here.`);
|
|
20
|
+
return { cmd: quote(cmd), args: list.map(quote), options: { ...options, shell: true } };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// spawnSync that works for npm on Windows; an unsafe argument comes back as { status: 1, error }
|
|
24
|
+
function runSync(cmd, args = [], options = {}) {
|
|
25
|
+
try {
|
|
26
|
+
const p = prepare(cmd, args, options);
|
|
27
|
+
return spawnSync(p.cmd, p.args, p.options);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
return { status: 1, error };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// spawn that works for .cmd programs (electron-builder.cmd …) on Windows
|
|
34
|
+
function start(cmd, args = [], options = {}) {
|
|
35
|
+
const p = prepare(cmd, args, options);
|
|
36
|
+
return spawn(p.cmd, p.args, p.options);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = { runSync, start, isCmdFile, prepare };
|
package/docs/Docs.kreftjs
CHANGED
|
@@ -524,7 +524,7 @@ on ready {
|
|
|
524
524
|
.dv-results .none { color: var(--dv-muted); cursor: default; }
|
|
525
525
|
.dv-modal-foot { display: flex; gap: 16px; padding: 9px 14px; border-top: 1px solid var(--dv-line); font-size: 12px; color: var(--dv-muted); }
|
|
526
526
|
|
|
527
|
-
.dv-top { position: fixed; inset-inline-end: 20px; bottom: 76px; /* above the DevTools button (bottom right, `
|
|
527
|
+
.dv-top { position: fixed; inset-inline-end: 20px; bottom: 76px; /* above the DevTools button (bottom right, `kreft dev` only) */ z-index: 40; display: grid; place-items: center; width: 40px; height: 40px; background: var(--background, #fff); color: var(--dv-text); border: 1px solid var(--dv-line); border-radius: 50%; cursor: pointer; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s, transform .2s; }
|
|
528
528
|
.dv-top.show { opacity: 1; pointer-events: auto; transform: none; }
|
|
529
529
|
|
|
530
530
|
/* narrow screens */
|