@krate/core 0.1.4 → 0.2.0-beta.1

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.
Files changed (3) hide show
  1. package/bin/krate +0 -0
  2. package/dist/cli.js +35 -2
  3. package/package.json +8 -8
package/bin/krate CHANGED
Binary file
package/dist/cli.js CHANGED
@@ -1,9 +1,32 @@
1
1
  import { readFileSync } from 'fs';
2
2
  import { join, dirname } from 'path';
3
3
  import { fileURLToPath } from 'url';
4
+ import { spawn } from 'child_process';
4
5
  import { execBinary } from './binary.js';
5
6
  const __dirname = dirname(fileURLToPath(import.meta.url));
6
7
  const version = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8')).version;
8
+ // scaffold delegates `krate init` / `krate create` to create-krate-app, the
9
+ // official scaffold CLI. It lives in the JS wrapper (not the Go binary) so it
10
+ // works on every platform and always pulls the latest published scaffold.
11
+ function scaffold(args) {
12
+ return new Promise((resolve, reject) => {
13
+ const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
14
+ const npxArgs = ['--yes', 'create-krate-app@latest'];
15
+ const dir = args[1];
16
+ if (dir)
17
+ npxArgs.push(dir);
18
+ const proc = spawn(npxCmd, npxArgs, { stdio: 'inherit' });
19
+ proc.on('close', (code) => {
20
+ if (code === 0)
21
+ resolve();
22
+ else
23
+ reject(new Error(`create-krate-app exited with code ${code}`));
24
+ });
25
+ proc.on('error', (err) => {
26
+ reject(new Error(`Failed to run create-krate-app: ${err.message}`));
27
+ });
28
+ });
29
+ }
7
30
  async function main() {
8
31
  const args = process.argv.slice(2);
9
32
  if (args.length === 0) {
@@ -12,16 +35,26 @@ async function main() {
12
35
  console.log('Commands:');
13
36
  console.log(' build Build project for production');
14
37
  console.log(' dev Start development server');
15
- console.log(' init Scaffold a new project');
38
+ console.log(' serve Build and serve for preview');
39
+ console.log(' init Scaffold a new project (alias: create)');
16
40
  console.log(' version Show version');
17
41
  process.exit(0);
18
42
  }
19
43
  const cmd = args[0];
20
44
  switch (cmd) {
45
+ case 'init':
46
+ case 'create':
47
+ try {
48
+ await scaffold(args);
49
+ }
50
+ catch (err) {
51
+ console.error(err.message);
52
+ process.exit(1);
53
+ }
54
+ break;
21
55
  case 'build':
22
56
  case 'dev':
23
57
  case 'serve':
24
- case 'init':
25
58
  try {
26
59
  await execBinary(args);
27
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krate/core",
3
- "version": "0.1.4",
3
+ "version": "0.2.0-beta.1",
4
4
  "description": "The Krate CLI — a Go-native static site generator with signal-based reactivity.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -41,13 +41,13 @@
41
41
  "typescript": "^5.5.0"
42
42
  },
43
43
  "optionalDependencies": {
44
- "@krate/core-darwin-arm64": "0.1.4",
45
- "@krate/core-darwin-x64": "0.1.4",
46
- "@krate/core-linux-arm64": "0.1.4",
47
- "@krate/core-linux-x64": "0.1.4",
48
- "@krate/core-linux-x64-musl": "0.1.4",
49
- "@krate/core-win32-arm64": "0.1.4",
50
- "@krate/core-win32-x64": "0.1.4"
44
+ "@krate/core-darwin-arm64": "0.2.0-beta.1",
45
+ "@krate/core-darwin-x64": "0.2.0-beta.1",
46
+ "@krate/core-linux-arm64": "0.2.0-beta.1",
47
+ "@krate/core-linux-x64": "0.2.0-beta.1",
48
+ "@krate/core-linux-x64-musl": "0.2.0-beta.1",
49
+ "@krate/core-win32-arm64": "0.2.0-beta.1",
50
+ "@krate/core-win32-x64": "0.2.0-beta.1"
51
51
  },
52
52
  "scripts": {
53
53
  "build": "tsc",