@worldware/msg-cli 0.4.1 → 0.5.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/README.md +13 -5
- package/dist/{chunk-QUPCXFIR.mjs → chunk-QOEKYM6W.mjs} +9 -0
- package/dist/commands/create/project.cjs +30 -6
- package/dist/commands/create/project.d.mts +2 -0
- package/dist/commands/create/project.d.ts +2 -0
- package/dist/commands/create/project.mjs +26 -7
- package/dist/lib/create-project-helpers.cjs +11 -0
- package/dist/lib/create-project-helpers.d.mts +14 -1
- package/dist/lib/create-project-helpers.d.ts +14 -1
- package/dist/lib/create-project-helpers.mjs +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,7 +79,7 @@ msg init -i
|
|
|
79
79
|
Create a new MsgProject file in the i18n projects directory. Requires `package.json` with `directories.i18n` and `directories.l10n` (run `msg init` first).
|
|
80
80
|
|
|
81
81
|
```bash
|
|
82
|
-
msg create project <projectName> [source] [targets...] [--extend <name>]
|
|
82
|
+
msg create project <projectName> [source] [targets...] [--extend <name>] [--format <MF1|MF2|NONE>]
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
| Argument | Required | Description |
|
|
@@ -93,17 +93,24 @@ msg create project <projectName> [source] [targets...] [--extend <name>]
|
|
|
93
93
|
| Flag | Short | Description |
|
|
94
94
|
|------------|-------|--------------------------------|
|
|
95
95
|
| `--extend` | `-e` | Extend an existing project. |
|
|
96
|
+
| `--format` | `-f` | Default message format: `MF1`, `MF2`, or `NONE` (default `MF2`). When omitted with `--extend`, inherits the base project's format. |
|
|
96
97
|
| `--help` | `-h` | Show help for create project. |
|
|
97
98
|
|
|
98
99
|
**Examples:**
|
|
99
100
|
|
|
100
101
|
```bash
|
|
101
|
-
# Create project myApp with source en and targets fr, de
|
|
102
|
+
# Create project myApp with source en and targets fr, de (format defaults to MF2)
|
|
102
103
|
msg create project myApp en fr de
|
|
103
104
|
|
|
104
|
-
#
|
|
105
|
+
# Create with MessageFormat 1 as the project default
|
|
106
|
+
msg create project myApp en fr -f MF1
|
|
107
|
+
|
|
108
|
+
# Extend an existing project (inherits source, targets, and format from base)
|
|
105
109
|
msg create project extendedApp --extend base
|
|
106
110
|
|
|
111
|
+
# Extend and override format
|
|
112
|
+
msg create project extendedApp --extend base --format NONE
|
|
113
|
+
|
|
107
114
|
# Extend and add/override locales
|
|
108
115
|
msg create project extendedApp en de --extend base
|
|
109
116
|
|
|
@@ -115,10 +122,11 @@ msg create project -h
|
|
|
115
122
|
|
|
116
123
|
- Writes the file to `i18n/projects/<projectName>.js` (always `.js`).
|
|
117
124
|
- Uses ES module or CommonJS export syntax based on `package.json` `"type"` or presence of `tsconfig.json`.
|
|
125
|
+
- Always includes `format` on `project` settings in the generated file (`MF2` by default).
|
|
118
126
|
- Generates a translation loader that imports from `l10n/translations` using the relative path from `i18n/projects` (from `directories` in package.json).
|
|
119
127
|
- Includes `pseudoLocale: 'en-XA'` by default (or inherits from the base project when extending), for use with msg's `getTranslation(pseudoLocale)` pseudolocalization support.
|
|
120
|
-
- With `--extend <name>`, merges target locales and pseudoLocale from the existing project. If `source` and `targets` are omitted, they are inherited from the base project.
|
|
121
|
-
- Errors if the project name already exists, package.json is missing or invalid,
|
|
128
|
+
- With `--extend <name>`, merges target locales and pseudoLocale from the existing project. If `source` and `targets` are omitted, they are inherited from the base project. If `--format` is omitted, format is inherited from the base project when set.
|
|
129
|
+
- Errors if the project name already exists, package.json is missing or invalid, required directories are not configured, or `--format` is not one of `MF1` / `MF2` / `NONE`.
|
|
122
130
|
|
|
123
131
|
### create resource
|
|
124
132
|
|
|
@@ -9,6 +9,13 @@ import {
|
|
|
9
9
|
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
10
10
|
import { dirname, join, relative } from "path";
|
|
11
11
|
import { pathToFileURL } from "url";
|
|
12
|
+
import { MSG_DEFAULT_FORMAT } from "@worldware/msg";
|
|
13
|
+
var CREATE_PROJECT_FORMATS = ["MF1", "MF2", "NONE"];
|
|
14
|
+
function resolveCreateProjectFormat(flagFormat, base) {
|
|
15
|
+
if (flagFormat) return flagFormat;
|
|
16
|
+
const inherited = base?.project?.format ?? base?.format;
|
|
17
|
+
return inherited ?? MSG_DEFAULT_FORMAT;
|
|
18
|
+
}
|
|
12
19
|
function calculateRelativePath(projectsDir, translationsDir) {
|
|
13
20
|
const rel = relative(projectsDir, translationsDir);
|
|
14
21
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
@@ -43,6 +50,8 @@ function loadPackageJsonForCreateProject(cwd) {
|
|
|
43
50
|
}
|
|
44
51
|
|
|
45
52
|
export {
|
|
53
|
+
CREATE_PROJECT_FORMATS,
|
|
54
|
+
resolveCreateProjectFormat,
|
|
46
55
|
calculateRelativePath,
|
|
47
56
|
importMsgProjectFile,
|
|
48
57
|
writeMsgProjectFile,
|
|
@@ -31,6 +31,7 @@ var import_path3 = require("path");
|
|
|
31
31
|
var import_fs2 = require("fs");
|
|
32
32
|
var import_path2 = require("path");
|
|
33
33
|
var import_url2 = require("url");
|
|
34
|
+
var import_msg = require("@worldware/msg");
|
|
34
35
|
|
|
35
36
|
// src/lib/create-resource-helpers.ts
|
|
36
37
|
var import_module = require("module");
|
|
@@ -124,6 +125,12 @@ async function dynamicImportFromUrl(url) {
|
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
// src/lib/create-project-helpers.ts
|
|
128
|
+
var CREATE_PROJECT_FORMATS = ["MF1", "MF2", "NONE"];
|
|
129
|
+
function resolveCreateProjectFormat(flagFormat, base) {
|
|
130
|
+
if (flagFormat) return flagFormat;
|
|
131
|
+
const inherited = base?.project?.format ?? base?.format;
|
|
132
|
+
return inherited ?? import_msg.MSG_DEFAULT_FORMAT;
|
|
133
|
+
}
|
|
127
134
|
function calculateRelativePath(projectsDir, translationsDir) {
|
|
128
135
|
const rel = (0, import_path2.relative)(projectsDir, translationsDir);
|
|
129
136
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
@@ -161,6 +168,12 @@ function loadPackageJsonForCreateProject(cwd) {
|
|
|
161
168
|
var CreateProject = class _CreateProject extends import_core.Command {
|
|
162
169
|
static description = "Create a new MsgProject file in the projects directory (i18n/projects)";
|
|
163
170
|
static strict = false;
|
|
171
|
+
static examples = [
|
|
172
|
+
"<%= config.bin %> <%= command.id %> myApp en fr de",
|
|
173
|
+
"<%= config.bin %> <%= command.id %> myApp en fr -f MF1",
|
|
174
|
+
"<%= config.bin %> <%= command.id %> extendedApp --extend base",
|
|
175
|
+
"<%= config.bin %> <%= command.id %> extendedApp --extend base --format NONE"
|
|
176
|
+
];
|
|
164
177
|
static args = {
|
|
165
178
|
projectName: import_core.Args.string({
|
|
166
179
|
required: false,
|
|
@@ -180,7 +193,13 @@ var CreateProject = class _CreateProject extends import_core.Command {
|
|
|
180
193
|
extend: import_core.Flags.string({
|
|
181
194
|
char: "e",
|
|
182
195
|
description: "Extend an existing project"
|
|
183
|
-
})
|
|
196
|
+
}),
|
|
197
|
+
format: import_core.Flags.option({
|
|
198
|
+
char: "f",
|
|
199
|
+
description: "Default message format for the project (MF1, MF2, or NONE)",
|
|
200
|
+
options: CREATE_PROJECT_FORMATS
|
|
201
|
+
// No default: omission must be distinguishable from an explicit MF2 for --extend inheritance.
|
|
202
|
+
})()
|
|
184
203
|
};
|
|
185
204
|
async run() {
|
|
186
205
|
const { argv, flags } = await this.parse(_CreateProject);
|
|
@@ -224,12 +243,15 @@ var CreateProject = class _CreateProject extends import_core.Command {
|
|
|
224
243
|
let targetLocales = {};
|
|
225
244
|
let pseudoLocale = "en-XA";
|
|
226
245
|
let resolvedSource = source?.trim();
|
|
246
|
+
let baseProject;
|
|
227
247
|
const hasUserSourceAndTargets = Boolean(resolvedSource && targets?.length && targets.some((t) => t?.trim()));
|
|
228
|
-
if (
|
|
229
|
-
const
|
|
248
|
+
if (useExtend) {
|
|
249
|
+
const extendName = flags.extend.trim();
|
|
250
|
+
const base = await importMsgProjectFile(projectsDir, extendName);
|
|
230
251
|
if (!base) {
|
|
231
|
-
this.error(`Project '${
|
|
252
|
+
this.error(`Project '${extendName}' could not be found to extend.`, { exit: 1 });
|
|
232
253
|
}
|
|
254
|
+
baseProject = base;
|
|
233
255
|
if (base.locales?.targetLocales && typeof base.locales.targetLocales === "object") {
|
|
234
256
|
targetLocales = { ...base.locales.targetLocales };
|
|
235
257
|
}
|
|
@@ -249,6 +271,7 @@ var CreateProject = class _CreateProject extends import_core.Command {
|
|
|
249
271
|
if (t?.trim()) targetLocales[t.trim()] = [t.trim()];
|
|
250
272
|
}
|
|
251
273
|
}
|
|
274
|
+
const format = resolveCreateProjectFormat(flags.format, baseProject);
|
|
252
275
|
const loaderPathLine = "const path = `${TRANSLATION_IMPORT_PATH}/${project}/${language}/${title}.json`;";
|
|
253
276
|
const loaderWarnLine = "console.warn(`Translations for locale ${language} could not be loaded.`, error);";
|
|
254
277
|
const loaderBody = `${loaderPathLine}
|
|
@@ -265,6 +288,7 @@ var CreateProject = class _CreateProject extends import_core.Command {
|
|
|
265
288
|
};
|
|
266
289
|
}`;
|
|
267
290
|
const importPath = relPath.replace(/\\/g, "/");
|
|
291
|
+
const projectSettings = `project: { name: ${JSON.stringify(projectName)}, version: 1, format: ${JSON.stringify(format)} }`;
|
|
268
292
|
const content = isEsm ? `import { MsgProject } from '@worldware/msg';
|
|
269
293
|
|
|
270
294
|
const TRANSLATION_IMPORT_PATH = ${JSON.stringify(importPath)};
|
|
@@ -273,7 +297,7 @@ const loader = async (project, title, language) => {
|
|
|
273
297
|
};
|
|
274
298
|
|
|
275
299
|
export default MsgProject.create({
|
|
276
|
-
|
|
300
|
+
${projectSettings},
|
|
277
301
|
locales: {
|
|
278
302
|
sourceLocale: ${JSON.stringify(resolvedSource)},
|
|
279
303
|
pseudoLocale: ${JSON.stringify(pseudoLocale)},
|
|
@@ -289,7 +313,7 @@ const loader = async (project, title, language) => {
|
|
|
289
313
|
};
|
|
290
314
|
|
|
291
315
|
module.exports = MsgProject.create({
|
|
292
|
-
|
|
316
|
+
${projectSettings},
|
|
293
317
|
locales: {
|
|
294
318
|
sourceLocale: ${JSON.stringify(resolvedSource)},
|
|
295
319
|
pseudoLocale: ${JSON.stringify(pseudoLocale)},
|
|
@@ -7,6 +7,7 @@ import { Command } from '@oclif/core';
|
|
|
7
7
|
declare class CreateProject extends Command {
|
|
8
8
|
static description: string;
|
|
9
9
|
static strict: boolean;
|
|
10
|
+
static examples: string[];
|
|
10
11
|
static args: {
|
|
11
12
|
projectName: _oclif_core_lib_interfaces_parser_js.Arg<string | undefined, Record<string, unknown>>;
|
|
12
13
|
source: _oclif_core_lib_interfaces_parser_js.Arg<string | undefined, Record<string, unknown>>;
|
|
@@ -15,6 +16,7 @@ declare class CreateProject extends Command {
|
|
|
15
16
|
static flags: {
|
|
16
17
|
help: _oclif_core_lib_interfaces_parser_js.BooleanFlag<void>;
|
|
17
18
|
extend: _oclif_core_lib_interfaces_parser_js.OptionFlag<string | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
|
19
|
+
format: _oclif_core_lib_interfaces_parser_js.OptionFlag<"MF1" | "MF2" | "NONE" | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
|
18
20
|
};
|
|
19
21
|
run(): Promise<void>;
|
|
20
22
|
}
|
|
@@ -7,6 +7,7 @@ import { Command } from '@oclif/core';
|
|
|
7
7
|
declare class CreateProject extends Command {
|
|
8
8
|
static description: string;
|
|
9
9
|
static strict: boolean;
|
|
10
|
+
static examples: string[];
|
|
10
11
|
static args: {
|
|
11
12
|
projectName: _oclif_core_lib_interfaces_parser_js.Arg<string | undefined, Record<string, unknown>>;
|
|
12
13
|
source: _oclif_core_lib_interfaces_parser_js.Arg<string | undefined, Record<string, unknown>>;
|
|
@@ -15,6 +16,7 @@ declare class CreateProject extends Command {
|
|
|
15
16
|
static flags: {
|
|
16
17
|
help: _oclif_core_lib_interfaces_parser_js.BooleanFlag<void>;
|
|
17
18
|
extend: _oclif_core_lib_interfaces_parser_js.OptionFlag<string | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
|
19
|
+
format: _oclif_core_lib_interfaces_parser_js.OptionFlag<"MF1" | "MF2" | "NONE" | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
|
18
20
|
};
|
|
19
21
|
run(): Promise<void>;
|
|
20
22
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CREATE_PROJECT_FORMATS,
|
|
2
3
|
calculateRelativePath,
|
|
3
4
|
importMsgProjectFile,
|
|
4
5
|
loadPackageJsonForCreateProject,
|
|
6
|
+
resolveCreateProjectFormat,
|
|
5
7
|
writeMsgProjectFile
|
|
6
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-QOEKYM6W.mjs";
|
|
7
9
|
import "../../chunk-PO2Z7EWJ.mjs";
|
|
8
10
|
import {
|
|
9
11
|
findPackageJsonPath
|
|
@@ -16,6 +18,12 @@ import { join } from "path";
|
|
|
16
18
|
var CreateProject = class _CreateProject extends Command {
|
|
17
19
|
static description = "Create a new MsgProject file in the projects directory (i18n/projects)";
|
|
18
20
|
static strict = false;
|
|
21
|
+
static examples = [
|
|
22
|
+
"<%= config.bin %> <%= command.id %> myApp en fr de",
|
|
23
|
+
"<%= config.bin %> <%= command.id %> myApp en fr -f MF1",
|
|
24
|
+
"<%= config.bin %> <%= command.id %> extendedApp --extend base",
|
|
25
|
+
"<%= config.bin %> <%= command.id %> extendedApp --extend base --format NONE"
|
|
26
|
+
];
|
|
19
27
|
static args = {
|
|
20
28
|
projectName: Args.string({
|
|
21
29
|
required: false,
|
|
@@ -35,7 +43,13 @@ var CreateProject = class _CreateProject extends Command {
|
|
|
35
43
|
extend: Flags.string({
|
|
36
44
|
char: "e",
|
|
37
45
|
description: "Extend an existing project"
|
|
38
|
-
})
|
|
46
|
+
}),
|
|
47
|
+
format: Flags.option({
|
|
48
|
+
char: "f",
|
|
49
|
+
description: "Default message format for the project (MF1, MF2, or NONE)",
|
|
50
|
+
options: CREATE_PROJECT_FORMATS
|
|
51
|
+
// No default: omission must be distinguishable from an explicit MF2 for --extend inheritance.
|
|
52
|
+
})()
|
|
39
53
|
};
|
|
40
54
|
async run() {
|
|
41
55
|
const { argv, flags } = await this.parse(_CreateProject);
|
|
@@ -79,12 +93,15 @@ var CreateProject = class _CreateProject extends Command {
|
|
|
79
93
|
let targetLocales = {};
|
|
80
94
|
let pseudoLocale = "en-XA";
|
|
81
95
|
let resolvedSource = source?.trim();
|
|
96
|
+
let baseProject;
|
|
82
97
|
const hasUserSourceAndTargets = Boolean(resolvedSource && targets?.length && targets.some((t) => t?.trim()));
|
|
83
|
-
if (
|
|
84
|
-
const
|
|
98
|
+
if (useExtend) {
|
|
99
|
+
const extendName = flags.extend.trim();
|
|
100
|
+
const base = await importMsgProjectFile(projectsDir, extendName);
|
|
85
101
|
if (!base) {
|
|
86
|
-
this.error(`Project '${
|
|
102
|
+
this.error(`Project '${extendName}' could not be found to extend.`, { exit: 1 });
|
|
87
103
|
}
|
|
104
|
+
baseProject = base;
|
|
88
105
|
if (base.locales?.targetLocales && typeof base.locales.targetLocales === "object") {
|
|
89
106
|
targetLocales = { ...base.locales.targetLocales };
|
|
90
107
|
}
|
|
@@ -104,6 +121,7 @@ var CreateProject = class _CreateProject extends Command {
|
|
|
104
121
|
if (t?.trim()) targetLocales[t.trim()] = [t.trim()];
|
|
105
122
|
}
|
|
106
123
|
}
|
|
124
|
+
const format = resolveCreateProjectFormat(flags.format, baseProject);
|
|
107
125
|
const loaderPathLine = "const path = `${TRANSLATION_IMPORT_PATH}/${project}/${language}/${title}.json`;";
|
|
108
126
|
const loaderWarnLine = "console.warn(`Translations for locale ${language} could not be loaded.`, error);";
|
|
109
127
|
const loaderBody = `${loaderPathLine}
|
|
@@ -120,6 +138,7 @@ var CreateProject = class _CreateProject extends Command {
|
|
|
120
138
|
};
|
|
121
139
|
}`;
|
|
122
140
|
const importPath = relPath.replace(/\\/g, "/");
|
|
141
|
+
const projectSettings = `project: { name: ${JSON.stringify(projectName)}, version: 1, format: ${JSON.stringify(format)} }`;
|
|
123
142
|
const content = isEsm ? `import { MsgProject } from '@worldware/msg';
|
|
124
143
|
|
|
125
144
|
const TRANSLATION_IMPORT_PATH = ${JSON.stringify(importPath)};
|
|
@@ -128,7 +147,7 @@ const loader = async (project, title, language) => {
|
|
|
128
147
|
};
|
|
129
148
|
|
|
130
149
|
export default MsgProject.create({
|
|
131
|
-
|
|
150
|
+
${projectSettings},
|
|
132
151
|
locales: {
|
|
133
152
|
sourceLocale: ${JSON.stringify(resolvedSource)},
|
|
134
153
|
pseudoLocale: ${JSON.stringify(pseudoLocale)},
|
|
@@ -144,7 +163,7 @@ const loader = async (project, title, language) => {
|
|
|
144
163
|
};
|
|
145
164
|
|
|
146
165
|
module.exports = MsgProject.create({
|
|
147
|
-
|
|
166
|
+
${projectSettings},
|
|
148
167
|
locales: {
|
|
149
168
|
sourceLocale: ${JSON.stringify(resolvedSource)},
|
|
150
169
|
pseudoLocale: ${JSON.stringify(pseudoLocale)},
|
|
@@ -20,15 +20,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/lib/create-project-helpers.ts
|
|
21
21
|
var create_project_helpers_exports = {};
|
|
22
22
|
__export(create_project_helpers_exports, {
|
|
23
|
+
CREATE_PROJECT_FORMATS: () => CREATE_PROJECT_FORMATS,
|
|
23
24
|
calculateRelativePath: () => calculateRelativePath,
|
|
24
25
|
importMsgProjectFile: () => importMsgProjectFile,
|
|
25
26
|
loadPackageJsonForCreateProject: () => loadPackageJsonForCreateProject,
|
|
27
|
+
resolveCreateProjectFormat: () => resolveCreateProjectFormat,
|
|
26
28
|
writeMsgProjectFile: () => writeMsgProjectFile
|
|
27
29
|
});
|
|
28
30
|
module.exports = __toCommonJS(create_project_helpers_exports);
|
|
29
31
|
var import_fs2 = require("fs");
|
|
30
32
|
var import_path2 = require("path");
|
|
31
33
|
var import_url2 = require("url");
|
|
34
|
+
var import_msg = require("@worldware/msg");
|
|
32
35
|
|
|
33
36
|
// src/lib/create-resource-helpers.ts
|
|
34
37
|
var import_module = require("module");
|
|
@@ -122,6 +125,12 @@ async function dynamicImportFromUrl(url) {
|
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
// src/lib/create-project-helpers.ts
|
|
128
|
+
var CREATE_PROJECT_FORMATS = ["MF1", "MF2", "NONE"];
|
|
129
|
+
function resolveCreateProjectFormat(flagFormat, base) {
|
|
130
|
+
if (flagFormat) return flagFormat;
|
|
131
|
+
const inherited = base?.project?.format ?? base?.format;
|
|
132
|
+
return inherited ?? import_msg.MSG_DEFAULT_FORMAT;
|
|
133
|
+
}
|
|
125
134
|
function calculateRelativePath(projectsDir, translationsDir) {
|
|
126
135
|
const rel = (0, import_path2.relative)(projectsDir, translationsDir);
|
|
127
136
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
@@ -156,8 +165,10 @@ function loadPackageJsonForCreateProject(cwd) {
|
|
|
156
165
|
}
|
|
157
166
|
// Annotate the CommonJS export names for ESM import in node:
|
|
158
167
|
0 && (module.exports = {
|
|
168
|
+
CREATE_PROJECT_FORMATS,
|
|
159
169
|
calculateRelativePath,
|
|
160
170
|
importMsgProjectFile,
|
|
161
171
|
loadPackageJsonForCreateProject,
|
|
172
|
+
resolveCreateProjectFormat,
|
|
162
173
|
writeMsgProjectFile
|
|
163
174
|
});
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { PackageJson } from './init-helpers.mjs';
|
|
2
|
+
import { MsgFormat } from '@worldware/msg';
|
|
2
3
|
|
|
3
4
|
/** Minimal type for MsgProject-like data we read from an existing project file. */
|
|
4
5
|
interface MsgProjectFileData {
|
|
5
6
|
project?: {
|
|
6
7
|
name?: string;
|
|
7
8
|
version?: number;
|
|
9
|
+
format?: MsgFormat;
|
|
8
10
|
};
|
|
11
|
+
/** Resolved format getter on MsgProject instances. */
|
|
12
|
+
format?: MsgFormat;
|
|
9
13
|
locales?: {
|
|
10
14
|
sourceLocale?: string;
|
|
11
15
|
pseudoLocale?: string;
|
|
@@ -13,6 +17,15 @@ interface MsgProjectFileData {
|
|
|
13
17
|
};
|
|
14
18
|
loader?: unknown;
|
|
15
19
|
}
|
|
20
|
+
/** Allowed `--format` / `-f` values for `create project`. */
|
|
21
|
+
declare const CREATE_PROJECT_FORMATS: readonly ["MF1", "MF2", "NONE"];
|
|
22
|
+
/**
|
|
23
|
+
* Resolves the format to write into a new MsgProject file.
|
|
24
|
+
* Explicit flag wins; otherwise inherit from an extended project; else library default.
|
|
25
|
+
* @param flagFormat - Value from `--format` / `-f`, if provided
|
|
26
|
+
* @param base - Imported base project when `--extend` is used
|
|
27
|
+
*/
|
|
28
|
+
declare function resolveCreateProjectFormat(flagFormat: MsgFormat | undefined, base?: MsgProjectFileData): MsgFormat;
|
|
16
29
|
/**
|
|
17
30
|
* Calculates the relative path from the i18n projects directory to the l10n translations directory.
|
|
18
31
|
* @param projectsDir - Absolute path to i18n/projects (e.g. root/i18n/projects)
|
|
@@ -47,4 +60,4 @@ declare function loadPackageJsonForCreateProject(cwd: string): PackageJson & {
|
|
|
47
60
|
};
|
|
48
61
|
};
|
|
49
62
|
|
|
50
|
-
export { type MsgProjectFileData, calculateRelativePath, importMsgProjectFile, loadPackageJsonForCreateProject, writeMsgProjectFile };
|
|
63
|
+
export { CREATE_PROJECT_FORMATS, type MsgProjectFileData, calculateRelativePath, importMsgProjectFile, loadPackageJsonForCreateProject, resolveCreateProjectFormat, writeMsgProjectFile };
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { PackageJson } from './init-helpers.js';
|
|
2
|
+
import { MsgFormat } from '@worldware/msg';
|
|
2
3
|
|
|
3
4
|
/** Minimal type for MsgProject-like data we read from an existing project file. */
|
|
4
5
|
interface MsgProjectFileData {
|
|
5
6
|
project?: {
|
|
6
7
|
name?: string;
|
|
7
8
|
version?: number;
|
|
9
|
+
format?: MsgFormat;
|
|
8
10
|
};
|
|
11
|
+
/** Resolved format getter on MsgProject instances. */
|
|
12
|
+
format?: MsgFormat;
|
|
9
13
|
locales?: {
|
|
10
14
|
sourceLocale?: string;
|
|
11
15
|
pseudoLocale?: string;
|
|
@@ -13,6 +17,15 @@ interface MsgProjectFileData {
|
|
|
13
17
|
};
|
|
14
18
|
loader?: unknown;
|
|
15
19
|
}
|
|
20
|
+
/** Allowed `--format` / `-f` values for `create project`. */
|
|
21
|
+
declare const CREATE_PROJECT_FORMATS: readonly ["MF1", "MF2", "NONE"];
|
|
22
|
+
/**
|
|
23
|
+
* Resolves the format to write into a new MsgProject file.
|
|
24
|
+
* Explicit flag wins; otherwise inherit from an extended project; else library default.
|
|
25
|
+
* @param flagFormat - Value from `--format` / `-f`, if provided
|
|
26
|
+
* @param base - Imported base project when `--extend` is used
|
|
27
|
+
*/
|
|
28
|
+
declare function resolveCreateProjectFormat(flagFormat: MsgFormat | undefined, base?: MsgProjectFileData): MsgFormat;
|
|
16
29
|
/**
|
|
17
30
|
* Calculates the relative path from the i18n projects directory to the l10n translations directory.
|
|
18
31
|
* @param projectsDir - Absolute path to i18n/projects (e.g. root/i18n/projects)
|
|
@@ -47,4 +60,4 @@ declare function loadPackageJsonForCreateProject(cwd: string): PackageJson & {
|
|
|
47
60
|
};
|
|
48
61
|
};
|
|
49
62
|
|
|
50
|
-
export { type MsgProjectFileData, calculateRelativePath, importMsgProjectFile, loadPackageJsonForCreateProject, writeMsgProjectFile };
|
|
63
|
+
export { CREATE_PROJECT_FORMATS, type MsgProjectFileData, calculateRelativePath, importMsgProjectFile, loadPackageJsonForCreateProject, resolveCreateProjectFormat, writeMsgProjectFile };
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CREATE_PROJECT_FORMATS,
|
|
2
3
|
calculateRelativePath,
|
|
3
4
|
importMsgProjectFile,
|
|
4
5
|
loadPackageJsonForCreateProject,
|
|
6
|
+
resolveCreateProjectFormat,
|
|
5
7
|
writeMsgProjectFile
|
|
6
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-QOEKYM6W.mjs";
|
|
7
9
|
import "../chunk-PO2Z7EWJ.mjs";
|
|
8
10
|
import "../chunk-F7XZRKP7.mjs";
|
|
9
11
|
export {
|
|
12
|
+
CREATE_PROJECT_FORMATS,
|
|
10
13
|
calculateRelativePath,
|
|
11
14
|
importMsgProjectFile,
|
|
12
15
|
loadPackageJsonForCreateProject,
|
|
16
|
+
resolveCreateProjectFormat,
|
|
13
17
|
writeMsgProjectFile
|
|
14
18
|
};
|