create-magnetic-app 0.1.2 → 0.1.3
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/bin/create.js +1 -28
- package/package.json +1 -1
- package/src/index.js +1 -13
package/bin/create.js
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { scaffold } from '../src/index.js';
|
|
9
9
|
import { resolve } from 'path';
|
|
10
|
-
import { existsSync } from 'fs';
|
|
11
10
|
|
|
12
11
|
const args = process.argv.slice(2);
|
|
13
12
|
const name = args.find(a => !a.startsWith('--'));
|
|
@@ -34,35 +33,9 @@ const targetDir = dirFlag !== -1 && args[dirFlag + 1]
|
|
|
34
33
|
const tplFlag = args.indexOf('--template');
|
|
35
34
|
const template = tplFlag !== -1 && args[tplFlag + 1] ? args[tplFlag + 1] : 'todo';
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
const runtimePaths = [
|
|
39
|
-
resolve(import.meta.dirname, '../../../sdk-web-runtime/dist/magnetic.min.js'),
|
|
40
|
-
resolve(import.meta.dirname, '../../../../apps/task-board/public/magnetic.js'),
|
|
41
|
-
resolve(process.cwd(), 'js/packages/sdk-web-runtime/dist/magnetic.min.js'),
|
|
42
|
-
resolve(process.cwd(), 'apps/task-board/public/magnetic.js'),
|
|
43
|
-
];
|
|
44
|
-
let runtimeSrc = null;
|
|
45
|
-
for (const p of runtimePaths) {
|
|
46
|
-
if (existsSync(p)) { runtimeSrc = p; break; }
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Try to find transport.wasm
|
|
50
|
-
const wasmPaths = [
|
|
51
|
-
resolve(import.meta.dirname, '../../../magnetic-server/wasm/transport.wasm'),
|
|
52
|
-
resolve(import.meta.dirname, '../../../magnetic-cli/wasm/transport.wasm'),
|
|
53
|
-
resolve(process.cwd(), 'js/packages/magnetic-server/wasm/transport.wasm'),
|
|
54
|
-
];
|
|
55
|
-
let wasmSrc = null;
|
|
56
|
-
for (const p of wasmPaths) {
|
|
57
|
-
if (existsSync(p)) { wasmSrc = p; break; }
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const dir = scaffold(targetDir, { name, template, runtimeSrc, wasmSrc });
|
|
36
|
+
const dir = scaffold(targetDir, { name, template });
|
|
61
37
|
console.log(`\n✓ Created Magnetic app: ${name}`);
|
|
62
38
|
console.log(` ${dir}\n`);
|
|
63
39
|
console.log(` Next steps:`);
|
|
64
40
|
console.log(` cd ${name}`);
|
|
65
41
|
console.log(` magnetic dev\n`);
|
|
66
|
-
if (!runtimeSrc) {
|
|
67
|
-
console.log(` ⚠ Client runtime (magnetic.js) not found — copy it to public/magnetic.js`);
|
|
68
|
-
}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -19,15 +19,13 @@
|
|
|
19
19
|
* Developer writes ONLY pages/components + server/state.ts.
|
|
20
20
|
* The @magnetic/cli handles bundling, bridge generation, and server management.
|
|
21
21
|
*/
|
|
22
|
-
import { mkdirSync, writeFileSync,
|
|
22
|
+
import { mkdirSync, writeFileSync, existsSync } from 'fs';
|
|
23
23
|
import { join, resolve } from 'path';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* @param {string} dest — target directory
|
|
27
27
|
* @param {object} opts
|
|
28
28
|
* @param {string} opts.name — project name
|
|
29
|
-
* @param {string} [opts.runtimeSrc] — path to magnetic.js to copy
|
|
30
|
-
* @param {string} [opts.wasmSrc] — path to transport.wasm to copy
|
|
31
29
|
* @param {string} [opts.template] — template name: "blank" | "todo" (default: "todo")
|
|
32
30
|
* @param {object} [opts.files] — extra files to write: { relativePath: content }
|
|
33
31
|
*/
|
|
@@ -73,16 +71,6 @@ export function scaffold(dest, opts = {}) {
|
|
|
73
71
|
writeFileSync(join(dir, 'README.md'), readme(name));
|
|
74
72
|
writeFileSync(join(dir, 'GUIDE.md'), guide(name));
|
|
75
73
|
|
|
76
|
-
// Copy client runtime if available
|
|
77
|
-
if (opts.runtimeSrc && existsSync(opts.runtimeSrc)) {
|
|
78
|
-
copyFileSync(opts.runtimeSrc, join(dir, 'public/magnetic.js'));
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Copy transport WASM if available
|
|
82
|
-
if (opts.wasmSrc && existsSync(opts.wasmSrc)) {
|
|
83
|
-
copyFileSync(opts.wasmSrc, join(dir, 'public/transport.wasm'));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
74
|
// Write any extra files
|
|
87
75
|
if (opts.files) {
|
|
88
76
|
for (const [rel, content] of Object.entries(opts.files)) {
|