kreftjs 0.0.1-beta → 0.0.3-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 +3 -3
- package/bin/add.js +3 -3
- package/bin/electron.js +1 -1
- package/bin/kreftjs.js +0 -4
- package/bin/update.js +3 -3
- package/bin/win-spawn.js +39 -0
- package/docs/README.md +2 -2
- package/kreftjs.d.ts +1 -1
- package/kreftjs.js +2 -2
- package/package.json +3 -8
- package/templates/app/frontend/errors/ErrorMonitor.kreftjs +2 -2
- package/templates/app/frontend/kreftjs.d.ts +1 -1
- package/templates/app/frontend/kreftjs.js +2 -2
- package/templates/app/frontend/pages/Dashboard.kreftjs +1 -1
- package/templates/errors/ErrorMonitor.kreftjs +1 -1
package/README.md
CHANGED
|
@@ -75,12 +75,12 @@ Views are escaped, logins use HttpOnly cookies with CSRF protection, passwords u
|
|
|
75
75
|
|
|
76
76
|
## Migrating from Som.js
|
|
77
77
|
|
|
78
|
-
Kreft is Som.js under a new name: the package is `kreftjs` (version 0.0.
|
|
78
|
+
Kreft is Som.js under a new name: the package is `kreftjs` (version 0.0.3-beta), the command is `kreftjs`, the global is `Kreftjs` and component files end in `.kreftjs`. The old names keep working, so an existing project runs without edits. New files and everything the tools write use the new names. Move over when it suits you. (`kreft` was an earlier spelling of the new name; it is accepted in the same places.)
|
|
79
79
|
|
|
80
80
|
| Som.js | Kreft | Still works? |
|
|
81
81
|
|---|---|---|
|
|
82
|
-
| `npm i -g somjs` | `npm i -g kreftjs` |
|
|
83
|
-
| `som dev`, `som build`, `som make:page` … | `kreftjs dev`, `kreftjs build`, `kreftjs make:page` … |
|
|
82
|
+
| `npm i -g somjs` | `npm i -g kreftjs` | `kreft` is another name for `kreftjs`. Kreft does not install a `som` command, so it does not clash with an old Som.js (remove that with `npm rm -g somjs`). |
|
|
83
|
+
| `som dev`, `som build`, `som make:page` … | `kreftjs dev`, `kreftjs build`, `kreftjs make:page` … | Replace `som` with `kreftjs`. |
|
|
84
84
|
| `Counter.som` (and `Counter.kreft`) | `Counter.kreftjs` | Yes. All three extensions compile; a name that is missing with one extension is tried with the others (`layouts/app.kreftjs` finds `layouts/app.som`). |
|
|
85
85
|
| `s-if`, `s-each`, `s-model` … (every `s-` directive) | `k-if`, `k-each`, `k-model` … | Yes. Both prefixes are read in templates. |
|
|
86
86
|
| `<som-view>`, `<som-link>`, `<som-wait>`, `<som-component>`, `<som-yield>`, `<som-section>`, `<som-portal>` | `<kreft-view>`, `<kreft-link>` … | Yes. Both tag names work. |
|
package/bin/add.js
CHANGED
|
@@ -43,7 +43,7 @@ const fs = require('fs');
|
|
|
43
43
|
const path = require('path');
|
|
44
44
|
const https = require('https');
|
|
45
45
|
const readline = require('readline');
|
|
46
|
-
const {
|
|
46
|
+
const { runSync } = require('./win-spawn.js');
|
|
47
47
|
const { layout } = require('./layout.js');
|
|
48
48
|
const pkg = require('../package.json');
|
|
49
49
|
|
|
@@ -449,7 +449,7 @@ module.exports = async function add(args = []) {
|
|
|
449
449
|
installArgs.push(...targets);
|
|
450
450
|
|
|
451
451
|
console.log(` ${cyan('Executing:')} npm ${installArgs.join(' ')}\n`);
|
|
452
|
-
const res =
|
|
452
|
+
const res = runSync(npmCmd, installArgs, { stdio: 'inherit', cwd: project });
|
|
453
453
|
|
|
454
454
|
if (res.status !== 0) {
|
|
455
455
|
console.error(`\n ${red('✖ Failed to install packages.')}`);
|
|
@@ -739,7 +739,7 @@ function getInstalledPackageJson(projectDir, pkgName) {
|
|
|
739
739
|
|
|
740
740
|
function getAuditReport(npmCmd, projectDir) {
|
|
741
741
|
try {
|
|
742
|
-
const res =
|
|
742
|
+
const res = runSync(npmCmd, ['audit', '--json'], { cwd: projectDir, encoding: 'utf8' });
|
|
743
743
|
if (res.stdout) {
|
|
744
744
|
return JSON.parse(res.stdout);
|
|
745
745
|
}
|
package/bin/electron.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
const fs = require('fs');
|
|
13
13
|
const path = require('path');
|
|
14
|
-
const { spawn } = require('
|
|
14
|
+
const { start: spawn } = require('./win-spawn.js');
|
|
15
15
|
|
|
16
16
|
function getProjectRoot(start = process.cwd()) {
|
|
17
17
|
const lay = require('./layout.js').layout(start);
|
package/bin/kreftjs.js
CHANGED
|
@@ -35,10 +35,6 @@ if (require.main === module && (process.argv.includes('--gc') || process.env.AUT
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const rawArgs = process.argv.slice(2).filter((a) => a !== '--gc');
|
|
38
|
-
// `som` (and `somjs`) still run this file, so an existing global install keeps working
|
|
39
|
-
if (require.main === module && /^(som|somjs)(\.cmd|\.js)?$/i.test(path.basename(process.argv[1] || ''))) {
|
|
40
|
-
console.error(' The "som" command is now "kreftjs" (Som.js is now Kreft). "som" still works for now: use "kreftjs" from here on.');
|
|
41
|
-
}
|
|
42
38
|
const [command = 'help', ...rest] = rawArgs;
|
|
43
39
|
|
|
44
40
|
const commands = {
|
package/bin/update.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
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}`);
|
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/README.md
CHANGED
|
@@ -82,7 +82,7 @@ npx kreftjs dev
|
|
|
82
82
|
### Check that it works
|
|
83
83
|
|
|
84
84
|
```bash
|
|
85
|
-
kreftjs --version # for example 0.0.
|
|
85
|
+
kreftjs --version # for example 0.0.3-beta
|
|
86
86
|
kreftjs about # Kreft and Node.js versions, this project's settings and drivers
|
|
87
87
|
kreftjs list # every command your version has
|
|
88
88
|
```
|
|
@@ -138,7 +138,7 @@ Kreft is Som.js under a new name (the package and command are `kreftjs`), and an
|
|
|
138
138
|
- **Files:** `.som` (and `.kreft`) files still compile, next to `.kreftjs` ones. A name that is missing with one extension is tried with the others. Everything the tools write is `.kreftjs`.
|
|
139
139
|
- **Templates:** `s-if`, `s-each` and every other `s-` directive are read as `k-if`, `k-each` …, and `<som-view>`, `<som-link>` … as `<kreft-view>`, `<kreft-link>` …
|
|
140
140
|
- **JavaScript:** `Som` and `Kreft` are other names for `Kreftjs` (same object; `Som` is deprecated), and `Som.compileSom` is `Kreftjs.compile`.
|
|
141
|
-
- **Command:** `
|
|
141
|
+
- **Command:** use `kreftjs` (or `kreft`). Kreft does not install a `som` command, so it can be installed next to an old Som.js without an `EEXIST` error; remove the old one with `npm rm -g somjs`.
|
|
142
142
|
- **Server code:** `require('somjs/server')` (also `som/server`, `@somjs/server`, `kreft/server`) still works; new code uses `require('kreftjs/server')`.
|
|
143
143
|
- **Settings:** `kreft.config.json`, `som.config.json` and `SOM_` environment variables (`SOM_SSR`, `SOM_ALLOWED_HOSTS` …) are read when the `kreftjs.config.json` file or the `KREFT_` variable is missing.
|
|
144
144
|
- **Cookies:** new projects use `kreft_session`, `kreft_2fa` and `kreft_bypass`. An existing project keeps its `som_` names until you change `app/Auth/Session.js`, and the framework's CSRF check accepts both.
|
package/kreftjs.d.ts
CHANGED
package/kreftjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Kreft v0.0.
|
|
2
|
+
* Kreft v0.0.3-beta — reactive by nature
|
|
3
3
|
* The .kreftjs component language (state · derive · action · when · watch · on),
|
|
4
4
|
* { } views with k-if / k-each / k-model, components, slots, router, stores,
|
|
5
5
|
* share / receive, event bus and a template engine.
|
|
@@ -5032,7 +5032,7 @@
|
|
|
5032
5032
|
stores, storeLog, busLog,
|
|
5033
5033
|
};
|
|
5034
5034
|
|
|
5035
|
-
const VERSION = '0.0.
|
|
5035
|
+
const VERSION = '0.0.3-beta';
|
|
5036
5036
|
const Kreftjs = {
|
|
5037
5037
|
version: VERSION,
|
|
5038
5038
|
// PUBLIC_ values from .env (kreftjs dev and kreftjs build put them here); never secrets
|
package/package.json
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kreftjs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3-beta",
|
|
4
4
|
"description": "A tiny reactive framework with its own component language (.kreftjs files): router with nested routes, stores, saved data, animations, an API client, hot reload, DevTools and a template engine.",
|
|
5
5
|
"main": "kreftjs.js",
|
|
6
6
|
"browser": "kreftjs.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"kreftjs": "bin/kreftjs.js",
|
|
9
|
-
"kreft": "bin/kreftjs.js"
|
|
10
|
-
"som": "bin/kreftjs.js"
|
|
9
|
+
"kreft": "bin/kreftjs.js"
|
|
11
10
|
},
|
|
12
11
|
"scripts": {
|
|
13
12
|
"dev": "node bin/kreftjs.js dev --api demo/db.json --db sqlite:demo/database/demo.db --migrations demo/database/migrations --server demo/server --backend demo --seed",
|
|
14
13
|
"start": "node bin/kreftjs.js dev --api demo/db.json --db sqlite:demo/database/demo.db --migrations demo/database/migrations --server demo/server --backend demo --seed",
|
|
15
14
|
"build": "node bin/kreftjs.js build demo --out dist/demo --include docs",
|
|
16
15
|
"preview": "node bin/kreftjs.js dev dist --api demo/db.json --db sqlite:demo/database/demo.db --migrations demo/database/migrations --server demo/server --backend demo --seed",
|
|
17
|
-
"test": "node --test test/security.test.js test/prerender.test.js test/seo.test.js test/rebrand.test.js test/noauth.test.js",
|
|
16
|
+
"test": "node --test test/security.test.js test/prerender.test.js test/seo.test.js test/rebrand.test.js test/noauth.test.js test/winspawn.test.js",
|
|
18
17
|
"electron": "kreftjs electron",
|
|
19
18
|
"electron:dev": "kreftjs electron:dev",
|
|
20
19
|
"electron:build": "kreftjs electron:build"
|
|
@@ -55,10 +54,6 @@
|
|
|
55
54
|
},
|
|
56
55
|
"./package.json": "./package.json"
|
|
57
56
|
},
|
|
58
|
-
"optionalDependencies": {
|
|
59
|
-
"esbuild": "^0.28.2",
|
|
60
|
-
"vite": "^6.2.0"
|
|
61
|
-
},
|
|
62
57
|
"allowScripts": {
|
|
63
58
|
"esbuild@0.28.2": true
|
|
64
59
|
},
|
|
@@ -90,7 +90,7 @@ action copyReport() {
|
|
|
90
90
|
<div class="badges">
|
|
91
91
|
<span class="badge danger-badge">HTTP {status}</span>
|
|
92
92
|
<span class="badge solid">{currentTitle}</span>
|
|
93
|
-
<span class="badge">Kreft {Kreftjs.version || '0.0.
|
|
93
|
+
<span class="badge">Kreft {Kreftjs.version || '0.0.3-beta'}</span>
|
|
94
94
|
</div>
|
|
95
95
|
<div class="actions">
|
|
96
96
|
<button class="sm" @click={copyReport}>{copied ? 'Copied Markdown' : 'Copy Report'}</button>
|
|
@@ -187,7 +187,7 @@ action copyReport() {
|
|
|
187
187
|
<h3>Kreft Runtime</h3>
|
|
188
188
|
<table>
|
|
189
189
|
<tbody>
|
|
190
|
-
<tr><th>Engine</th><td><code>Kreft v{Kreftjs.version || '0.0.
|
|
190
|
+
<tr><th>Engine</th><td><code>Kreft v{Kreftjs.version || '0.0.3-beta'}</code></td></tr>
|
|
191
191
|
<tr><th>Sanitizer</th><td><code>Active (cleanHtml / SafeHtml)</code></td></tr>
|
|
192
192
|
<tr><th>Environment</th><td><code>development (APP_DEBUG=true)</code></td></tr>
|
|
193
193
|
</tbody>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Kreft v0.0.
|
|
2
|
+
* Kreft v0.0.3-beta — reactive by nature
|
|
3
3
|
* The .kreftjs component language (state · derive · action · when · watch · on),
|
|
4
4
|
* { } views with k-if / k-each / k-model, components, slots, router, stores,
|
|
5
5
|
* share / receive, event bus and a template engine.
|
|
@@ -5032,7 +5032,7 @@
|
|
|
5032
5032
|
stores, storeLog, busLog,
|
|
5033
5033
|
};
|
|
5034
5034
|
|
|
5035
|
-
const VERSION = '0.0.
|
|
5035
|
+
const VERSION = '0.0.3-beta';
|
|
5036
5036
|
const Kreftjs = {
|
|
5037
5037
|
version: VERSION,
|
|
5038
5038
|
// PUBLIC_ values from .env (kreftjs dev and kreftjs build put them here); never secrets
|
|
@@ -110,7 +110,7 @@ load board = api.get('/api/dashboard')
|
|
|
110
110
|
<div class="info-list">
|
|
111
111
|
<div class="info-item">
|
|
112
112
|
<span class="info-label">Framework Engine</span>
|
|
113
|
-
<span class="info-value">Kreft {Kreftjs.version || '0.0.
|
|
113
|
+
<span class="info-value">Kreft {Kreftjs.version || '0.0.3-beta'}</span>
|
|
114
114
|
</div>
|
|
115
115
|
<div class="info-item">
|
|
116
116
|
<span class="info-label">Active Database</span>
|
|
@@ -116,7 +116,7 @@ action copyReport() {
|
|
|
116
116
|
<div class="hero-badges">
|
|
117
117
|
<span class="badge-exception">{currentTitle}</span>
|
|
118
118
|
<span class="badge-env">Node.js {typeof process !== 'undefined' ? process.version : 'v22.0.0'}</span>
|
|
119
|
-
<span class="badge-env">Kreft v0.0.
|
|
119
|
+
<span class="badge-env">Kreft v0.0.3-beta</span>
|
|
120
120
|
</div>
|
|
121
121
|
<h1 class="hero-error-message">{currentMessage}</h1>
|
|
122
122
|
</div>
|