primate 0.38.0 → 0.39.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/lib/commands/init.js +54 -51
- package/lib/public/i18n.d.ts +2 -0
- package/lib/public/i18n.js +2 -0
- package/lib/public/loader.d.ts +2 -0
- package/lib/public/loader.js +2 -0
- package/lib/public/session.d.ts +2 -0
- package/lib/public/session.js +2 -0
- package/package.json +6 -4
- package/lib/public/config/i18n.d.ts +0 -2
- package/lib/public/config/i18n.js +0 -2
- package/lib/public/config/session.d.ts +0 -2
- package/lib/public/config/session.js +0 -2
- package/lib/public/i18n/locale.d.ts +0 -2
- package/lib/public/i18n/locale.js +0 -2
- package/lib/public/route/hook.d.ts +0 -2
- package/lib/public/route/hook.js +0 -2
- package/lib/public/s/internal.d.ts +0 -2
- package/lib/public/s/internal.js +0 -2
package/lib/commands/init.js
CHANGED
|
@@ -135,9 +135,7 @@ const command_init = async () => {
|
|
|
135
135
|
// files
|
|
136
136
|
await gitignore(target);
|
|
137
137
|
await tsconfig_json(target, { frontends });
|
|
138
|
-
await app_config(target, { frontends, backends, runtime });
|
|
139
|
-
if (with_i18n)
|
|
140
|
-
await i18n_config(target);
|
|
138
|
+
await app_config(target, { frontends, backends, runtime, with_i18n });
|
|
141
139
|
if (with_sessions)
|
|
142
140
|
await session_config(target);
|
|
143
141
|
if (is.defined(db))
|
|
@@ -170,66 +168,70 @@ async function gitignore(root) {
|
|
|
170
168
|
].join("\n");
|
|
171
169
|
await gi.write(content);
|
|
172
170
|
}
|
|
173
|
-
|
|
174
|
-
const config =
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
.
|
|
171
|
+
function app_config_imports(choices) {
|
|
172
|
+
const config = `import config from "primate/config";`;
|
|
173
|
+
const frontend = choices.frontends.length > 0
|
|
174
|
+
? choices.frontends
|
|
175
|
+
.map(i => `import ${to_ident(i)} from "@primate/${i}";`)
|
|
176
|
+
.join("\n")
|
|
177
|
+
: false;
|
|
178
|
+
const backend = choices.backends.length > 0
|
|
179
|
+
? choices.backends
|
|
180
|
+
.map(i => `import ${to_ident(i)} from "@primate/${i}";`)
|
|
181
|
+
.join("\n")
|
|
182
|
+
: false;
|
|
183
|
+
const i18n = choices.with_i18n
|
|
184
|
+
? `import en from "../locales/en-US.ts";`
|
|
185
|
+
: false;
|
|
186
|
+
return [config, frontend, backend, i18n, "\n"].filter(Boolean).join("\n");
|
|
187
|
+
}
|
|
188
|
+
function app_config_export(choices) {
|
|
182
189
|
const modules = [
|
|
183
|
-
...
|
|
184
|
-
...
|
|
190
|
+
...choices.frontends.map((f) => `${to_ident(f)}()`),
|
|
191
|
+
...choices.backends.map((b) => `${to_ident(b)}()`),
|
|
185
192
|
];
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
193
|
+
const i18n = choices.with_i18n
|
|
194
|
+
? ` i18n: {
|
|
195
|
+
defaultLocale: "en-US",
|
|
196
|
+
locales: {
|
|
197
|
+
"en-US": en,
|
|
198
|
+
},
|
|
199
|
+
},\n`
|
|
200
|
+
: "";
|
|
201
|
+
return `export default config({
|
|
202
|
+
${i18n} modules: [
|
|
203
|
+
${modules.join(",\n ")},
|
|
192
204
|
],
|
|
193
205
|
});`;
|
|
194
|
-
await config.write(body);
|
|
195
206
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const locale = `import locale from "primate/i18n/locale";
|
|
204
|
-
export default locale({
|
|
205
|
-
hi: "Hello",
|
|
206
|
-
placeheld: "Hello, {name}",
|
|
207
|
-
});`;
|
|
208
|
-
await en_us.write(locale);
|
|
209
|
-
const config = `import en from "#locale/en-US";
|
|
210
|
-
import i18n from "primate/config/i18n";
|
|
207
|
+
async function app_config(root, choices) {
|
|
208
|
+
const config = root.join("config").join("app.ts");
|
|
209
|
+
await config.directory.create();
|
|
210
|
+
if (choices.with_i18n) {
|
|
211
|
+
const locale = root.join("locales").join("en-US.ts");
|
|
212
|
+
await locale.directory.create();
|
|
213
|
+
await locale.write(`import i18n from "primate/i18n";
|
|
211
214
|
|
|
212
|
-
export default i18n({
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
await i18i.write(config);
|
|
215
|
+
export default i18n.locale({
|
|
216
|
+
hi: "Hi",
|
|
217
|
+
placeheld: "Hello, {name}",
|
|
218
|
+
});`);
|
|
219
|
+
}
|
|
220
|
+
await config.write(app_config_imports(choices) + app_config_export(choices));
|
|
219
221
|
}
|
|
220
222
|
async function session_config(root) {
|
|
221
223
|
const file = root.join("config").join("session.ts");
|
|
222
224
|
await file.directory.create();
|
|
223
|
-
const body = `import session from "primate/
|
|
224
|
-
export default session({})
|
|
225
|
+
const body = `import session from "primate/session";
|
|
226
|
+
export default session({}); `;
|
|
225
227
|
await file.write(body);
|
|
226
228
|
}
|
|
227
229
|
async function database_config(root, db) {
|
|
228
|
-
const file = root.join("config").join("
|
|
230
|
+
const file = root.join("config").join("db.ts");
|
|
229
231
|
await file.directory.create();
|
|
230
232
|
const ident = to_ident(db);
|
|
231
233
|
const body = `import ${ident} from "@primate/${db}";
|
|
232
|
-
export default ${ident}()
|
|
234
|
+
export default ${ident} (); `;
|
|
233
235
|
await file.write(body);
|
|
234
236
|
}
|
|
235
237
|
async function package_json(root, c) {
|
|
@@ -266,7 +268,6 @@ function safe(s) {
|
|
|
266
268
|
.replace(/[^a-z0-9._-]/g, "") || "primate-app";
|
|
267
269
|
}
|
|
268
270
|
function to_ident(token) {
|
|
269
|
-
// turn tokens like "web-components" into valid identifiers: "web_components"
|
|
270
271
|
return token.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
271
272
|
}
|
|
272
273
|
function compute_packages(args) {
|
|
@@ -344,17 +345,20 @@ async function tsconfig_json(root, opts) {
|
|
|
344
345
|
compilerOptions: {
|
|
345
346
|
baseUrl: "${configDir}",
|
|
346
347
|
paths: {
|
|
347
|
-
"#
|
|
348
|
+
"#app": ["config/app"],
|
|
348
349
|
"#session": ["config/session"],
|
|
349
|
-
"#
|
|
350
|
+
"#db": ["config/db"],
|
|
351
|
+
"#config/*": ["config/*"],
|
|
350
352
|
"#view/*": ["views/*"],
|
|
351
353
|
"#component/*": ["components/*"],
|
|
354
|
+
"#route/*": ["routes/*"],
|
|
352
355
|
"#store/*": ["stores/*"],
|
|
353
356
|
"#locale/*": ["locales/*"],
|
|
354
357
|
"#static/*": ["static/*"],
|
|
355
358
|
},
|
|
356
359
|
},
|
|
357
360
|
include: [
|
|
361
|
+
"client",
|
|
358
362
|
"config",
|
|
359
363
|
"views",
|
|
360
364
|
"components",
|
|
@@ -362,7 +366,6 @@ async function tsconfig_json(root, opts) {
|
|
|
362
366
|
"stores",
|
|
363
367
|
"locales",
|
|
364
368
|
"static",
|
|
365
|
-
"test",
|
|
366
369
|
],
|
|
367
370
|
exclude: ["node_modules"],
|
|
368
371
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "primate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.1",
|
|
4
4
|
"description": "The universal web framework",
|
|
5
5
|
"homepage": "https://primate.run",
|
|
6
6
|
"bugs": "https://github.com/primate-run/primate/issues",
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
"/lib/**/*.d.ts",
|
|
18
18
|
"!/**/*.spec.*"
|
|
19
19
|
],
|
|
20
|
-
"bin": "lib/bin.js",
|
|
21
20
|
"types": "lib/index.d.ts",
|
|
22
21
|
"dependencies": {
|
|
23
22
|
"@rcompat/cli": "^0.24.0",
|
|
@@ -28,7 +27,7 @@
|
|
|
28
27
|
"@rcompat/is": "^0.11.0",
|
|
29
28
|
"@rcompat/runtime": "^0.16.0",
|
|
30
29
|
"@rcompat/test": "^0.17.0",
|
|
31
|
-
"@primate/core": "^0.
|
|
30
|
+
"@primate/core": "^0.8.5"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {
|
|
34
33
|
"@rcompat/type": "^0.17.0"
|
|
@@ -59,8 +58,11 @@
|
|
|
59
58
|
}
|
|
60
59
|
},
|
|
61
60
|
"scripts": {
|
|
62
|
-
"build": "npm run clean &&
|
|
61
|
+
"build": "npm run clean && tsgo && cp src/app.tsconfig.json lib && cp src/types/app.d.ts lib && cp src/types/index.d.ts lib",
|
|
63
62
|
"clean": "rm -rf ./lib",
|
|
64
63
|
"lint": "eslint ."
|
|
64
|
+
},
|
|
65
|
+
"bin": {
|
|
66
|
+
"primate": "lib/bin.js"
|
|
65
67
|
}
|
|
66
68
|
}
|
package/lib/public/route/hook.js
DELETED
package/lib/public/s/internal.js
DELETED