@jxsuite/create 0.19.0 → 0.26.0
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/{generate.js → generate.ts} +22 -24
- package/{index.js → index.ts} +2 -2
- package/package.json +20 -17
- package/template/gitignore +1 -1
- package/template/layouts/base.json +1 -3
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared project generation logic. Used by both the CLI scaffolder and the Studio server endpoint.
|
|
3
|
-
*/
|
|
1
|
+
/** Shared project generation logic. Used by both the CLI scaffolder and the Studio server endpoint. */
|
|
4
2
|
|
|
5
3
|
import { mkdir, writeFile, cp } from "node:fs/promises";
|
|
6
4
|
import { join, dirname } from "node:path";
|
|
@@ -10,14 +8,12 @@ import { existsSync } from "node:fs";
|
|
|
10
8
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
9
|
const TEMPLATE_DIR = join(__dirname, "template");
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* }} ProjectOptions
|
|
20
|
-
*/
|
|
11
|
+
export interface ProjectOptions {
|
|
12
|
+
name: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
adapter?: "static" | "cloudflare-pages" | "node" | "bun";
|
|
16
|
+
}
|
|
21
17
|
|
|
22
18
|
/**
|
|
23
19
|
* Generate a new Jx project at the given path.
|
|
@@ -25,7 +21,7 @@ const TEMPLATE_DIR = join(__dirname, "template");
|
|
|
25
21
|
* @param {string} destPath — absolute path to the project directory
|
|
26
22
|
* @param {ProjectOptions} opts
|
|
27
23
|
*/
|
|
28
|
-
export async function generateProject(destPath, opts) {
|
|
24
|
+
export async function generateProject(destPath: string, opts: ProjectOptions) {
|
|
29
25
|
const { name, description = "", url = "", adapter = "static" } = opts;
|
|
30
26
|
|
|
31
27
|
if (existsSync(destPath)) {
|
|
@@ -52,10 +48,8 @@ export async function generateProject(destPath, opts) {
|
|
|
52
48
|
]);
|
|
53
49
|
}
|
|
54
50
|
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
*/
|
|
58
|
-
function buildProjectJson({ name, description, url, adapter }) {
|
|
51
|
+
/** @param {ProjectOptions} opts */
|
|
52
|
+
function buildProjectJson({ name, description, url, adapter }: ProjectOptions) {
|
|
59
53
|
const $head = [
|
|
60
54
|
{
|
|
61
55
|
tagName: "meta",
|
|
@@ -70,8 +64,7 @@ function buildProjectJson({ name, description, url, adapter }) {
|
|
|
70
64
|
});
|
|
71
65
|
}
|
|
72
66
|
|
|
73
|
-
|
|
74
|
-
const build = {
|
|
67
|
+
const build: { outDir: string; format: string; trailingSlash: string; adapter?: string } = {
|
|
75
68
|
outDir: "./dist",
|
|
76
69
|
format: "directory",
|
|
77
70
|
trailingSlash: "always",
|
|
@@ -106,17 +99,22 @@ function buildProjectJson({ name, description, url, adapter }) {
|
|
|
106
99
|
};
|
|
107
100
|
}
|
|
108
101
|
|
|
109
|
-
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
/** @param {{ name: string; description?: string; adapter?: string }} opts */
|
|
103
|
+
function buildPackageJson({
|
|
104
|
+
name,
|
|
105
|
+
description,
|
|
106
|
+
adapter,
|
|
107
|
+
}: {
|
|
108
|
+
name: string;
|
|
109
|
+
description?: string;
|
|
110
|
+
adapter?: string;
|
|
111
|
+
}) {
|
|
113
112
|
const slug = name
|
|
114
113
|
.toLowerCase()
|
|
115
114
|
.replace(/[^a-z0-9]+/g, "-")
|
|
116
115
|
.replace(/^-|-$/g, "");
|
|
117
116
|
|
|
118
|
-
|
|
119
|
-
const devDependencies = {
|
|
117
|
+
const devDependencies: Record<string, string> = {
|
|
120
118
|
"@jxsuite/compiler": "^0.19.0",
|
|
121
119
|
"@jxsuite/runtime": "^0.19.0",
|
|
122
120
|
};
|
package/{index.js → index.ts}
RENAMED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { createInterface } from "node:readline/promises";
|
|
9
9
|
import { stdin, stdout } from "node:process";
|
|
10
10
|
import { resolve, basename } from "node:path";
|
|
11
|
-
import { generateProject } from "./generate
|
|
11
|
+
import { generateProject } from "./generate";
|
|
12
12
|
|
|
13
13
|
const dest = process.argv[2];
|
|
14
14
|
if (!dest) {
|
|
@@ -35,7 +35,7 @@ Deployment adapter:
|
|
|
35
35
|
const adapterChoice = await rl.question("Adapter [1]: ");
|
|
36
36
|
rl.close();
|
|
37
37
|
|
|
38
|
-
const adapterMap = {
|
|
38
|
+
const adapterMap = { 1: "static", 2: "cloudflare-pages", 3: "node", 4: "bun" };
|
|
39
39
|
const adapter = adapterMap[adapterChoice] || "static";
|
|
40
40
|
|
|
41
41
|
await generateProject(destPath, { name, description, url, adapter });
|
package/package.json
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
},
|
|
2
|
+
"name": "@jxsuite/create",
|
|
3
|
+
"version": "0.26.0",
|
|
5
4
|
"description": "Scaffold a new Jx project",
|
|
6
|
-
"exports": {
|
|
7
|
-
".": "./index.js",
|
|
8
|
-
"./generate": "./generate.js"
|
|
9
|
-
},
|
|
10
|
-
"files": [
|
|
11
|
-
"index.js",
|
|
12
|
-
"generate.js",
|
|
13
|
-
"template/"
|
|
14
|
-
],
|
|
15
5
|
"license": "MIT",
|
|
16
|
-
"name": "@jxsuite/create",
|
|
17
6
|
"repository": {
|
|
18
|
-
"directory": "packages/create",
|
|
19
7
|
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/jxsuite/jx.git"
|
|
8
|
+
"url": "git+https://github.com/jxsuite/jx.git",
|
|
9
|
+
"directory": "packages/create"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"create-jxsuite": "./index.ts"
|
|
21
13
|
},
|
|
14
|
+
"files": [
|
|
15
|
+
"index.ts",
|
|
16
|
+
"generate.ts",
|
|
17
|
+
"template/"
|
|
18
|
+
],
|
|
22
19
|
"type": "module",
|
|
23
|
-
"
|
|
24
|
-
|
|
20
|
+
"exports": {
|
|
21
|
+
".": "./index.ts",
|
|
22
|
+
"./generate": "./generate.ts"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"provenance": true
|
|
26
|
+
}
|
|
27
|
+
}
|
package/template/gitignore
CHANGED