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.
@@ -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
- async function app_config(root, c) {
174
- const config = root.join("config").join("app.ts");
175
- await config.directory.create();
176
- const frontend_imports = c.frontends
177
- .map((f) => `import ${to_ident(f)} from "@primate/${f}";`)
178
- .join("\n");
179
- const backend_imports = c.backends
180
- .map((b) => `import ${to_ident(b)} from "@primate/${b}";`)
181
- .join("\n");
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
- ...c.frontends.map((f) => `${to_ident(f)}()`),
184
- ...c.backends.map((b) => `${to_ident(b)}()`),
190
+ ...choices.frontends.map((f) => `${to_ident(f)}()`),
191
+ ...choices.backends.map((b) => `${to_ident(b)}()`),
185
192
  ];
186
- const body = `import config from "primate/config";
187
- ${frontend_imports}
188
- ${backend_imports}
189
- export default config({
190
- modules: [
191
- ${modules.join(",\n ")}
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
- // i18n scaffold: config + a default locale file
197
- async function i18n_config(root) {
198
- const locales = root.join("locales");
199
- const en_us = locales.join("en-US.ts");
200
- const i18i = root.join("config").join("i18n.ts");
201
- await en_us.directory.create();
202
- await i18i.directory.create();
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
- defaultLocale: "en-US",
214
- locales: {
215
- "en-US": en,
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/config/session";
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("database").join("index.ts");
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
- "#config/*": ["config/*"],
348
+ "#app": ["config/app"],
348
349
  "#session": ["config/session"],
349
- "#i18n": ["config/i18n"],
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
  };
@@ -0,0 +1,2 @@
1
+ export { default } from "@primate/core/i18n";
2
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "@primate/core/i18n";
2
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "@primate/core/loader";
2
+ //# sourceMappingURL=loader.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "@primate/core/loader";
2
+ //# sourceMappingURL=loader.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "@primate/core/session";
2
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "@primate/core/session";
2
+ //# sourceMappingURL=session.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "primate",
3
- "version": "0.38.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.7.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 && tsc && cp src/app.tsconfig.json lib && cp src/types/app.d.ts lib && cp src/types/index.d.ts lib",
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
  }
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/i18n/config";
2
- //# sourceMappingURL=i18n.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/i18n/config";
2
- //# sourceMappingURL=i18n.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/session/config";
2
- //# sourceMappingURL=session.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/session/config";
2
- //# sourceMappingURL=session.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/i18n/locale";
2
- //# sourceMappingURL=locale.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/i18n/locale";
2
- //# sourceMappingURL=locale.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/route/hook";
2
- //# sourceMappingURL=hook.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/route/hook";
2
- //# sourceMappingURL=hook.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/i18n/sInternal";
2
- //# sourceMappingURL=internal.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/i18n/sInternal";
2
- //# sourceMappingURL=internal.js.map