primate 0.14.0 → 0.14.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.
- package/package.json +1 -1
- package/src/commands/create.js +24 -2
package/package.json
CHANGED
package/src/commands/create.js
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
import {Path} from "runtime-compat/fs";
|
|
2
|
-
|
|
2
|
+
import package_json from "../../package.json" assert {type: "json"};
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const createModule = async () => {
|
|
5
|
+
const space = 2;
|
|
6
|
+
try {
|
|
7
|
+
// will throw if cannot find a package.json up the filesystem hierarchy
|
|
8
|
+
await Path.root();
|
|
9
|
+
} catch (error) {
|
|
10
|
+
const rootConfig = JSON.stringify({
|
|
11
|
+
name: "primate-app",
|
|
12
|
+
private: true,
|
|
13
|
+
dependencies: {
|
|
14
|
+
primate: `^${package_json.version}`,
|
|
15
|
+
},
|
|
16
|
+
scripts: {
|
|
17
|
+
run: "npx primate",
|
|
18
|
+
},
|
|
19
|
+
type: "module",
|
|
20
|
+
}, null, space);
|
|
21
|
+
await Path.resolve().join("package.json").file.write(rootConfig);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
5
24
|
|
|
6
25
|
const createConfig = async env => {
|
|
26
|
+
const name = "primate.config.js";
|
|
27
|
+
const template = "export default {};";
|
|
7
28
|
const root = (await Path.root()).join(name);
|
|
8
29
|
if (await root.exists) {
|
|
9
30
|
env.log.warn(`${root} already exists`);
|
|
@@ -14,6 +35,7 @@ const createConfig = async env => {
|
|
|
14
35
|
};
|
|
15
36
|
|
|
16
37
|
export default async env => {
|
|
38
|
+
await createModule();
|
|
17
39
|
await createConfig(env);
|
|
18
40
|
};
|
|
19
41
|
|