@vocoder/cli 0.7.0 → 0.9.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/dist/bin.mjs +34 -14
- package/dist/bin.mjs.map +1 -1
- package/dist/{chunk-ADQ4WVOA.mjs → chunk-IZN5HVYD.mjs} +16 -4
- package/dist/{chunk-ADQ4WVOA.mjs.map → chunk-IZN5HVYD.mjs.map} +1 -1
- package/dist/lib.d.mts +2 -0
- package/dist/lib.mjs +1 -1
- package/dist/lib.mjs.map +1 -1
- package/package.json +3 -3
package/dist/bin.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
getPackagesToInstall,
|
|
8
8
|
getSetupSnippets,
|
|
9
9
|
loadVocoderConfig
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-IZN5HVYD.mjs";
|
|
11
11
|
|
|
12
12
|
// src/bin.ts
|
|
13
13
|
import { Command } from "commander";
|
|
@@ -745,10 +745,26 @@ function clearAuthData() {
|
|
|
745
745
|
// src/utils/write-config.ts
|
|
746
746
|
import { existsSync, writeFileSync as writeFileSync2 } from "fs";
|
|
747
747
|
import { join as join2 } from "path";
|
|
748
|
+
function findExistingConfig(cwd = process.cwd()) {
|
|
749
|
+
for (const name of [
|
|
750
|
+
"vocoder.config.ts",
|
|
751
|
+
"vocoder.config.js",
|
|
752
|
+
"vocoder.config.json"
|
|
753
|
+
]) {
|
|
754
|
+
const candidate = join2(cwd, name);
|
|
755
|
+
if (existsSync(candidate)) return candidate;
|
|
756
|
+
}
|
|
757
|
+
return null;
|
|
758
|
+
}
|
|
748
759
|
function writeVocoderConfig(options) {
|
|
749
|
-
const {
|
|
750
|
-
|
|
751
|
-
|
|
760
|
+
const {
|
|
761
|
+
targetBranches = ["main"],
|
|
762
|
+
useTypeScript = true,
|
|
763
|
+
cwd = process.cwd()
|
|
764
|
+
} = options;
|
|
765
|
+
if (findExistingConfig(cwd)) return null;
|
|
766
|
+
const ext = useTypeScript ? "ts" : "js";
|
|
767
|
+
const configPath = join2(cwd, `vocoder.config.${ext}`);
|
|
752
768
|
const branchesStr = targetBranches.map((b) => `'${b}'`).join(", ");
|
|
753
769
|
const content = `import { defineConfig } from '@vocoder/config'
|
|
754
770
|
|
|
@@ -767,9 +783,9 @@ export default defineConfig({
|
|
|
767
783
|
`;
|
|
768
784
|
try {
|
|
769
785
|
writeFileSync2(configPath, content, "utf-8");
|
|
770
|
-
return
|
|
786
|
+
return `vocoder.config.${ext}`;
|
|
771
787
|
} catch {
|
|
772
|
-
return
|
|
788
|
+
return null;
|
|
773
789
|
}
|
|
774
790
|
}
|
|
775
791
|
|
|
@@ -2002,6 +2018,7 @@ function printPlanLimitMessage(apiUrl, message) {
|
|
|
2002
2018
|
function runScaffold(params) {
|
|
2003
2019
|
const { sourceLocale, targetBranches } = params;
|
|
2004
2020
|
const detection = detectLocalEcosystem();
|
|
2021
|
+
const useTypeScript = detection.isTypeScript;
|
|
2005
2022
|
if (detection.ecosystem) {
|
|
2006
2023
|
const frameworkLabel = detection.framework ?? detection.ecosystem;
|
|
2007
2024
|
const pmLabel = detection.packageManager;
|
|
@@ -2075,12 +2092,13 @@ function runScaffold(params) {
|
|
|
2075
2092
|
printCodeBlock(step.code);
|
|
2076
2093
|
if (i < steps.length - 1) p5.log.message("");
|
|
2077
2094
|
}
|
|
2078
|
-
const written = writeVocoderConfig({ targetBranches });
|
|
2095
|
+
const written = writeVocoderConfig({ targetBranches, useTypeScript });
|
|
2079
2096
|
if (written) {
|
|
2080
|
-
p5.log.success(`Created ${chalk6.cyan(
|
|
2081
|
-
} else if (!
|
|
2097
|
+
p5.log.success(`Created ${chalk6.cyan(written)}`);
|
|
2098
|
+
} else if (!findExistingConfig(process.cwd())) {
|
|
2099
|
+
const ext = useTypeScript ? "ts" : "js";
|
|
2082
2100
|
p5.log.warn(
|
|
2083
|
-
|
|
2101
|
+
`Could not write vocoder.config.${ext} \u2014 create it manually with your extraction patterns.`
|
|
2084
2102
|
);
|
|
2085
2103
|
}
|
|
2086
2104
|
p5.log.message("");
|
|
@@ -2352,8 +2370,9 @@ async function init(options = {}) {
|
|
|
2352
2370
|
return 1;
|
|
2353
2371
|
}
|
|
2354
2372
|
}
|
|
2355
|
-
const
|
|
2356
|
-
|
|
2373
|
+
const isTs = detectLocalEcosystem().isTypeScript;
|
|
2374
|
+
const written = writeVocoderConfig({ targetBranches: exactMatch.targetBranches ?? ["main"], useTypeScript: isTs });
|
|
2375
|
+
if (written) p5.log.success(`Created ${chalk6.cyan(written)}`);
|
|
2357
2376
|
p5.outro("Vocoder is already set up for this repository.");
|
|
2358
2377
|
return 0;
|
|
2359
2378
|
}
|
|
@@ -2361,8 +2380,9 @@ async function init(options = {}) {
|
|
|
2361
2380
|
const wholeRepo = lookup.existingApps.find((a) => a.appDir === "");
|
|
2362
2381
|
if (wholeRepo) {
|
|
2363
2382
|
p5.log.success(`Project: ${chalk6.bold(wholeRepo.projectName)}`);
|
|
2364
|
-
const
|
|
2365
|
-
|
|
2383
|
+
const isTs = detectLocalEcosystem().isTypeScript;
|
|
2384
|
+
const written = writeVocoderConfig({ targetBranches: ["main"], useTypeScript: isTs });
|
|
2385
|
+
if (written) p5.log.success(`Created ${chalk6.cyan(written)}`);
|
|
2366
2386
|
p5.outro("Vocoder is already set up for this repository.");
|
|
2367
2387
|
return 0;
|
|
2368
2388
|
}
|