@saltcorn/cli 1.1.3-beta.0 → 1.1.3-beta.10

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.
@@ -2186,10 +2186,10 @@
2186
2186
  },
2187
2187
  "description": "Produce translation files with LLM",
2188
2188
  "flags": {
2189
- "module": {
2190
- "char": "m",
2191
- "description": "Module to translate (in development)",
2192
- "name": "module",
2189
+ "plugin": {
2190
+ "char": "p",
2191
+ "description": "Plugin to translate",
2192
+ "name": "plugin",
2193
2193
  "hasDynamicHelp": false,
2194
2194
  "multiple": false,
2195
2195
  "type": "option"
@@ -2212,5 +2212,5 @@
2212
2212
  ]
2213
2213
  }
2214
2214
  },
2215
- "version": "1.1.3-beta.0"
2215
+ "version": "1.1.3-beta.10"
2216
2216
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@saltcorn/cli",
3
3
  "description": "Command-line interface for Saltcorn, open-source no-code platform",
4
4
  "homepage": "https://saltcorn.com",
5
- "version": "1.1.3-beta.0",
5
+ "version": "1.1.3-beta.10",
6
6
  "author": "Tom Nielsen @glutamate",
7
7
  "bin": {
8
8
  "saltcorn": "./bin/saltcorn"
@@ -11,13 +11,13 @@
11
11
  "dependencies": {
12
12
  "@oclif/core": "^4.2.4",
13
13
  "@oclif/plugin-plugins": "^5.4.26",
14
- "@saltcorn/admin-models": "1.1.3-beta.0",
15
- "@saltcorn/common-code": "1.1.3-beta.0",
16
- "@saltcorn/data": "1.1.3-beta.0",
17
- "@saltcorn/mobile-app": "1.1.3-beta.0",
18
- "@saltcorn/mobile-builder": "1.1.3-beta.0",
19
- "@saltcorn/plugins-loader": "1.1.3-beta.0",
20
- "@saltcorn/server": "1.1.3-beta.0",
14
+ "@saltcorn/admin-models": "1.1.3-beta.10",
15
+ "@saltcorn/common-code": "1.1.3-beta.10",
16
+ "@saltcorn/data": "1.1.3-beta.10",
17
+ "@saltcorn/mobile-app": "1.1.3-beta.10",
18
+ "@saltcorn/mobile-builder": "1.1.3-beta.10",
19
+ "@saltcorn/plugins-loader": "1.1.3-beta.10",
20
+ "@saltcorn/server": "1.1.3-beta.10",
21
21
  "contractis": "^0.1.0",
22
22
  "dateformat": "^4.6.3",
23
23
  "inquirer": "^12.3.3",
@@ -23,8 +23,7 @@ class TranslateCommand extends Command {
23
23
  const { args, flags } = await this.parse(TranslateCommand);
24
24
  await init_some_tenants();
25
25
  await maybe_as_tenant(null, async () => {
26
- console.log(getState().functions);
27
- const dir = path.join(
26
+ let dir = path.join(
28
27
  __dirname,
29
28
  "..",
30
29
  "..",
@@ -33,10 +32,17 @@ class TranslateCommand extends Command {
33
32
  "server",
34
33
  "locales",
35
34
  );
35
+ if (flags.plugin) {
36
+ const location = getState().plugin_locations[flags.plugin];
37
+ if (!location) throw new Error("Plugin not found");
38
+ dir = path.join(location, "locales");
39
+ }
36
40
  const english = JSON.parse(fs.readFileSync(path.join(dir, "en.json")));
37
- const locale = JSON.parse(
38
- fs.readFileSync(path.join(dir, args.locale + ".json")),
39
- );
41
+ const filePath = path.join(dir, args.locale + ".json");
42
+
43
+ const locale = fs.existsSync(filePath)
44
+ ? JSON.parse(fs.readFileSync(filePath))
45
+ : {};
40
46
 
41
47
  let count = 0;
42
48
  for (const key of Object.keys(english)) {
@@ -45,10 +51,10 @@ class TranslateCommand extends Command {
45
51
  continue;
46
52
  }
47
53
  process.stdout.write(`Translating ${key} to: `);
48
- const answer = await getState().functions.llm_generate.run(
49
- key,
50
- { systemPrompt: systemPrompt(args.locale), temperature: 0 },
51
- );
54
+ const answer = await getState().functions.llm_generate.run(key, {
55
+ systemPrompt: systemPrompt(args.locale),
56
+ temperature: 0,
57
+ });
52
58
  console.log(answer);
53
59
  locale[key] = answer;
54
60
  count += 1;
@@ -58,6 +64,18 @@ class TranslateCommand extends Command {
58
64
  );
59
65
  //if (count > 10) break;
60
66
  }
67
+ if (flags.plugin) {
68
+ //console.log(getState().plugins[flags.plugin]);
69
+ const plugin = await Plugin.findOne({
70
+ name: { or: [flags.plugin, `@saltcorn/${flags.plugin}`] },
71
+ });
72
+ if (plugin?.source === "local") {
73
+ fs.writeFileSync(
74
+ path.join(plugin.location, "locales", args.locale + ".json"),
75
+ JSON.stringify(locale, null, 2),
76
+ );
77
+ }
78
+ }
61
79
  });
62
80
  this.exit(0);
63
81
  }
@@ -98,9 +116,9 @@ TranslateCommand.description = `Produce translation files with LLM`;
98
116
  * @type {object}
99
117
  */
100
118
  TranslateCommand.flags = {
101
- module: Flags.string({
102
- char: "m",
103
- description: "Module to translate (in development)",
119
+ plugin: Flags.string({
120
+ char: "p",
121
+ description: "Plugin to translate",
104
122
  }),
105
123
  };
106
124