@openworkflow/cli 0.4.3 → 0.4.5
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/commands.d.ts.map +1 -1
- package/dist/commands.js +84 -131
- package/dist/config.js +1 -1
- package/package.json +7 -7
package/dist/commands.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAkC,MAAM,aAAa,CAAC;AAiC3E,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,gBAAiB,SAAQ,cAAc;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAoBnC;AAED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAkC,MAAM,aAAa,CAAC;AAiC3E,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,gBAAiB,SAAQ,cAAc;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAoBnC;AAED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwHtE;AAED;;;GAGG;AACH,wBAAsB,MAAM,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmDxE;AAED,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,cAAc,CAAC;AAE/D;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAuEf;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,YAAY,EAAE;QACZ,KAAK,EAAE,SAAS,CAAC;QACjB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;KACzB,CAAC;CACH,CAYA;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAavE;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8D7E;AA8OD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,MAAM,EACf,cAAc,GAAE,MAAM,EAAO,GAC5B,MAAM,EAAE,CA4CV;AAwVD,UAAU,oBAAoB;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAoCD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,IAAI,GACjD,MAAM,CAER;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,IAAI,GACjD,MAAM,CAER;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,IAAI,GACjD,MAAM,CAER;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,IAAI,GACjD,MAAM,CAER"}
|
package/dist/commands.js
CHANGED
|
@@ -50,11 +50,8 @@ export async function init(options = {}) {
|
|
|
50
50
|
message: `Config file already exists at ${configFile}. Override it?`,
|
|
51
51
|
initialValue: false,
|
|
52
52
|
});
|
|
53
|
-
if (!shouldOverride || p.isCancel(shouldOverride))
|
|
54
|
-
|
|
55
|
-
// eslint-disable-next-line unicorn/no-process-exit
|
|
56
|
-
process.exit(0);
|
|
57
|
-
}
|
|
53
|
+
if (!shouldOverride || p.isCancel(shouldOverride))
|
|
54
|
+
cancelSetup();
|
|
58
55
|
configFileToDelete = configFile;
|
|
59
56
|
}
|
|
60
57
|
const backendChoice = await p.select({
|
|
@@ -78,11 +75,8 @@ export async function init(options = {}) {
|
|
|
78
75
|
],
|
|
79
76
|
initialValue: "sqlite",
|
|
80
77
|
});
|
|
81
|
-
if (p.isCancel(backendChoice))
|
|
82
|
-
|
|
83
|
-
// eslint-disable-next-line unicorn/no-process-exit
|
|
84
|
-
process.exit(0);
|
|
85
|
-
}
|
|
78
|
+
if (p.isCancel(backendChoice))
|
|
79
|
+
cancelSetup();
|
|
86
80
|
const spinner = p.spinner();
|
|
87
81
|
// detect package manager & install packages
|
|
88
82
|
spinner.start("Detecting package manager...");
|
|
@@ -104,11 +98,8 @@ export async function init(options = {}) {
|
|
|
104
98
|
message: "Install packages and set up project files?",
|
|
105
99
|
initialValue: true,
|
|
106
100
|
});
|
|
107
|
-
if (p.isCancel(shouldSetup))
|
|
108
|
-
|
|
109
|
-
// eslint-disable-next-line unicorn/no-process-exit
|
|
110
|
-
process.exit(0);
|
|
111
|
-
}
|
|
101
|
+
if (p.isCancel(shouldSetup))
|
|
102
|
+
cancelSetup();
|
|
112
103
|
if (!shouldSetup) {
|
|
113
104
|
p.outro("Setup skipped.");
|
|
114
105
|
return;
|
|
@@ -324,6 +315,14 @@ export async function dashboard(options = {}) {
|
|
|
324
315
|
});
|
|
325
316
|
}
|
|
326
317
|
// -----------------------------------------------------------------------------
|
|
318
|
+
/**
|
|
319
|
+
* Show a canceled-setup message and exit the process with status 0.
|
|
320
|
+
*/
|
|
321
|
+
function cancelSetup() {
|
|
322
|
+
p.cancel("Setup canceled.");
|
|
323
|
+
// eslint-disable-next-line unicorn/no-process-exit
|
|
324
|
+
process.exit(0);
|
|
325
|
+
}
|
|
327
326
|
/**
|
|
328
327
|
* Get workflow directories from config.
|
|
329
328
|
* @param config - The loaded config
|
|
@@ -390,10 +389,7 @@ function assertNoDuplicateWorkflows(workflows) {
|
|
|
390
389
|
function warnAboutDuplicateWorkflows(workflows) {
|
|
391
390
|
const duplicates = findDuplicateWorkflows(workflows);
|
|
392
391
|
for (const duplicate of duplicates) {
|
|
393
|
-
|
|
394
|
-
? ` (version: ${duplicate.version})`
|
|
395
|
-
: "";
|
|
396
|
-
consola.warn(`Duplicate workflow detected: "${duplicate.name}"${versionStr}`);
|
|
392
|
+
consola.warn(`Duplicate workflow detected: ${formatWorkflowIdentity(duplicate.name, duplicate.version)}`);
|
|
397
393
|
consola.warn("Multiple files export a workflow with the same name and version.");
|
|
398
394
|
}
|
|
399
395
|
}
|
|
@@ -561,9 +557,8 @@ async function importWorkflows(files) {
|
|
|
561
557
|
// extract workflow exports (named and default)
|
|
562
558
|
for (const [key, value] of Object.entries(module)) {
|
|
563
559
|
if (isWorkflow(value)) {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
consola.debug(`Found workflow "${workflow.spec.name}" in ${file} (${key})`);
|
|
560
|
+
workflows.push(value);
|
|
561
|
+
consola.debug(`Found workflow "${value.spec.name}" in ${file} (${key})`);
|
|
567
562
|
}
|
|
568
563
|
}
|
|
569
564
|
}
|
|
@@ -646,24 +641,36 @@ function createConfigFile(configFileName) {
|
|
|
646
641
|
spinner.stop(`Config written to ${configDestPath}`);
|
|
647
642
|
}
|
|
648
643
|
/**
|
|
649
|
-
*
|
|
650
|
-
*
|
|
644
|
+
* Write a file under the `openworkflow/` project directory, skipping when a
|
|
645
|
+
* file with the same name already exists. Progress is surfaced via the clack
|
|
646
|
+
* spinner using the provided label (e.g. "client file").
|
|
647
|
+
* @param label - Lowercase label describing the file (used in spinner text)
|
|
648
|
+
* @param fileName - Filename to write inside `openworkflow/`
|
|
649
|
+
* @param content - File contents to write when the file does not exist
|
|
651
650
|
*/
|
|
652
|
-
function
|
|
651
|
+
function writeWorkflowFileIfMissing(label, fileName, content) {
|
|
653
652
|
const spinner = p.spinner();
|
|
654
653
|
const workflowsDir = path.join(process.cwd(), "openworkflow");
|
|
655
654
|
if (!existsSync(workflowsDir)) {
|
|
656
655
|
mkdirSync(workflowsDir, { recursive: true });
|
|
657
656
|
}
|
|
658
|
-
const
|
|
659
|
-
if (existsSync(
|
|
660
|
-
spinner.start(
|
|
661
|
-
|
|
657
|
+
const destPath = path.join(workflowsDir, fileName);
|
|
658
|
+
if (existsSync(destPath)) {
|
|
659
|
+
spinner.start(`Checking ${label}...`);
|
|
660
|
+
const capitalized = label.charAt(0).toUpperCase() + label.slice(1);
|
|
661
|
+
spinner.stop(`${capitalized} already exists at ${destPath}`);
|
|
662
662
|
return;
|
|
663
663
|
}
|
|
664
|
-
spinner.start(
|
|
665
|
-
writeFileSync(
|
|
666
|
-
spinner.stop(`Created
|
|
664
|
+
spinner.start(`Creating ${label}...`);
|
|
665
|
+
writeFileSync(destPath, content, "utf8");
|
|
666
|
+
spinner.stop(`Created ${label} at ${destPath}`);
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Create hello-world runner file.
|
|
670
|
+
* @param runFileName - The runner filename to write
|
|
671
|
+
*/
|
|
672
|
+
function createRunFile(runFileName) {
|
|
673
|
+
writeWorkflowFileIfMissing("hello-world runner", runFileName, HELLO_WORLD_RUNNER);
|
|
667
674
|
}
|
|
668
675
|
/**
|
|
669
676
|
* Create client file.
|
|
@@ -671,41 +678,14 @@ function createRunFile(runFileName) {
|
|
|
671
678
|
* @param clientFileName - The client filename to write
|
|
672
679
|
*/
|
|
673
680
|
function createClientFile(backendChoice, clientFileName) {
|
|
674
|
-
|
|
675
|
-
const workflowsDir = path.join(process.cwd(), "openworkflow");
|
|
676
|
-
if (!existsSync(workflowsDir)) {
|
|
677
|
-
mkdirSync(workflowsDir, { recursive: true });
|
|
678
|
-
}
|
|
679
|
-
const clientDestPath = path.join(workflowsDir, clientFileName);
|
|
680
|
-
if (existsSync(clientDestPath)) {
|
|
681
|
-
spinner.start("Checking client file...");
|
|
682
|
-
spinner.stop(`Client file already exists at ${clientDestPath}`);
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
spinner.start("Creating client file...");
|
|
686
|
-
const clientTemplate = getClientTemplate(backendChoice);
|
|
687
|
-
writeFileSync(clientDestPath, clientTemplate, "utf8");
|
|
688
|
-
spinner.stop(`Created client file at ${clientDestPath}`);
|
|
681
|
+
writeWorkflowFileIfMissing("client file", clientFileName, getClientTemplate(backendChoice));
|
|
689
682
|
}
|
|
690
683
|
/**
|
|
691
684
|
* Create example workflow.
|
|
692
685
|
* @param exampleWorkflowFileName - The example workflow filename to write
|
|
693
686
|
*/
|
|
694
687
|
function createExampleWorkflow(exampleWorkflowFileName) {
|
|
695
|
-
|
|
696
|
-
const workflowsDir = path.join(process.cwd(), "openworkflow");
|
|
697
|
-
if (!existsSync(workflowsDir)) {
|
|
698
|
-
mkdirSync(workflowsDir, { recursive: true });
|
|
699
|
-
}
|
|
700
|
-
const helloWorldDestPath = path.join(workflowsDir, exampleWorkflowFileName);
|
|
701
|
-
if (existsSync(helloWorldDestPath)) {
|
|
702
|
-
spinner.start("Checking example (hello-world) workflow...");
|
|
703
|
-
spinner.stop(`Example (hello-world) workflow already exists at ${helloWorldDestPath}`);
|
|
704
|
-
return;
|
|
705
|
-
}
|
|
706
|
-
spinner.start("Creating example (hello-world) workflow...");
|
|
707
|
-
writeFileSync(helloWorldDestPath, HELLO_WORLD_WORKFLOW, "utf8");
|
|
708
|
-
spinner.stop(`Created example (hello-world) workflow at ${helloWorldDestPath}`);
|
|
688
|
+
writeWorkflowFileIfMissing("example (hello-world) workflow", exampleWorkflowFileName, HELLO_WORLD_WORKFLOW);
|
|
709
689
|
}
|
|
710
690
|
/**
|
|
711
691
|
* Update .gitignore for SQLite.
|
|
@@ -718,8 +698,8 @@ function updateGitignoreForSqlite() {
|
|
|
718
698
|
const gitignorePath = path.join(process.cwd(), ".gitignore");
|
|
719
699
|
const spinner = p.spinner();
|
|
720
700
|
spinner.start("Updating .gitignore...");
|
|
721
|
-
const
|
|
722
|
-
spinner.stop(
|
|
701
|
+
const added = ensureGitignoreEntry(gitignorePath, "openworkflow/backend.db*");
|
|
702
|
+
spinner.stop(added
|
|
723
703
|
? "Added openworkflow/backend.db* to .gitignore"
|
|
724
704
|
: "openworkflow/backend.db* already in .gitignore");
|
|
725
705
|
}
|
|
@@ -745,38 +725,33 @@ function addWorkerScriptToPackageJson() {
|
|
|
745
725
|
consola.warn("Could not add worker script to package.json");
|
|
746
726
|
}
|
|
747
727
|
}
|
|
728
|
+
/**
|
|
729
|
+
* Append a line to a file if no existing line matches. Creates the file if it
|
|
730
|
+
* doesn't exist.
|
|
731
|
+
* @param filePath - Path to the file
|
|
732
|
+
* @param line - Line to append (without a trailing newline)
|
|
733
|
+
* @param matchesExisting - Predicate that returns true when an existing line
|
|
734
|
+
* should be treated as already representing `line`
|
|
735
|
+
* @returns Whether the line was appended
|
|
736
|
+
*/
|
|
737
|
+
function appendLineIfMissing(filePath, line, matchesExisting) {
|
|
738
|
+
const content = existsSync(filePath) ? readFileSync(filePath, "utf8") : "";
|
|
739
|
+
if (content.split("\n").some((existing) => matchesExisting(existing))) {
|
|
740
|
+
return false;
|
|
741
|
+
}
|
|
742
|
+
const separator = content === "" || content.endsWith("\n") ? "" : "\n";
|
|
743
|
+
writeFileSync(filePath, `${content}${separator}${line}\n`, "utf8");
|
|
744
|
+
return true;
|
|
745
|
+
}
|
|
748
746
|
/**
|
|
749
747
|
* Ensure a specific entry exists in a .gitignore file. Creates the file if it
|
|
750
748
|
* doesn't exist, appends the entry if not present.
|
|
751
749
|
* @param gitignorePath - Path to the .gitignore file
|
|
752
750
|
* @param entry - The entry to add (e.g. "openworkflow/backend.db*")
|
|
753
|
-
* @returns
|
|
751
|
+
* @returns Whether the entry was appended
|
|
754
752
|
*/
|
|
755
753
|
function ensureGitignoreEntry(gitignorePath, entry) {
|
|
756
|
-
|
|
757
|
-
let content = "";
|
|
758
|
-
if (fileExists) {
|
|
759
|
-
content = readFileSync(gitignorePath, "utf8");
|
|
760
|
-
}
|
|
761
|
-
// check if entry already exists
|
|
762
|
-
const lines = content.split("\n");
|
|
763
|
-
const hasEntry = lines.some((line) => line.trim() === entry);
|
|
764
|
-
if (hasEntry) {
|
|
765
|
-
return { added: false, created: false };
|
|
766
|
-
}
|
|
767
|
-
// add entry to .gitignore
|
|
768
|
-
let newContent;
|
|
769
|
-
if (content === "") {
|
|
770
|
-
newContent = `${entry}\n`;
|
|
771
|
-
}
|
|
772
|
-
else if (content.endsWith("\n")) {
|
|
773
|
-
newContent = `${content}${entry}\n`;
|
|
774
|
-
}
|
|
775
|
-
else {
|
|
776
|
-
newContent = `${content}\n${entry}\n`;
|
|
777
|
-
}
|
|
778
|
-
writeFileSync(gitignorePath, newContent, "utf8");
|
|
779
|
-
return { added: true, created: !fileExists };
|
|
754
|
+
return appendLineIfMissing(gitignorePath, entry, (line) => line.trim() === entry);
|
|
780
755
|
}
|
|
781
756
|
/**
|
|
782
757
|
* Add OPENWORKFLOW_POSTGRES_URL to .env file.
|
|
@@ -785,8 +760,8 @@ function updateEnvForPostgres() {
|
|
|
785
760
|
const envPath = path.join(process.cwd(), ".env");
|
|
786
761
|
const spinner = p.spinner();
|
|
787
762
|
spinner.start("Updating .env...");
|
|
788
|
-
const
|
|
789
|
-
spinner.stop(
|
|
763
|
+
const added = ensureEnvEntry(envPath, "OPENWORKFLOW_POSTGRES_URL", "postgresql://user:password@localhost:5432/openworkflow");
|
|
764
|
+
spinner.stop(added
|
|
790
765
|
? "Added OPENWORKFLOW_POSTGRES_URL to .env"
|
|
791
766
|
: "OPENWORKFLOW_POSTGRES_URL already in .env");
|
|
792
767
|
}
|
|
@@ -824,16 +799,24 @@ function readPackageJsonForDoctor() {
|
|
|
824
799
|
return null;
|
|
825
800
|
}
|
|
826
801
|
}
|
|
802
|
+
/**
|
|
803
|
+
* Pick the script file extension for generated files based on whether the
|
|
804
|
+
* project uses TypeScript.
|
|
805
|
+
* @param packageJson - Parsed package.json (or null if missing)
|
|
806
|
+
* @returns ".ts" when TypeScript is a dependency, otherwise ".js"
|
|
807
|
+
*/
|
|
808
|
+
function getScriptExtension(packageJson) {
|
|
809
|
+
return packageJson && hasDependency(packageJson, "typescript")
|
|
810
|
+
? ".ts"
|
|
811
|
+
: ".js";
|
|
812
|
+
}
|
|
827
813
|
/**
|
|
828
814
|
* Determine the config filename to write during init.
|
|
829
815
|
* @param packageJson - Parsed package.json (or null if missing)
|
|
830
816
|
* @returns The config file name to create
|
|
831
817
|
*/
|
|
832
818
|
export function getConfigFileName(packageJson) {
|
|
833
|
-
|
|
834
|
-
return "openworkflow.config.ts";
|
|
835
|
-
}
|
|
836
|
-
return "openworkflow.config.js";
|
|
819
|
+
return `openworkflow.config${getScriptExtension(packageJson)}`;
|
|
837
820
|
}
|
|
838
821
|
/**
|
|
839
822
|
* Determine the example workflow filename to write during init.
|
|
@@ -841,9 +824,7 @@ export function getConfigFileName(packageJson) {
|
|
|
841
824
|
* @returns The example workflow file name to create
|
|
842
825
|
*/
|
|
843
826
|
export function getExampleWorkflowFileName(packageJson) {
|
|
844
|
-
|
|
845
|
-
const extension = path.extname(configFileName) || ".js";
|
|
846
|
-
return `hello-world${extension}`;
|
|
827
|
+
return `hello-world${getScriptExtension(packageJson)}`;
|
|
847
828
|
}
|
|
848
829
|
/**
|
|
849
830
|
* Determine the hello-world runner filename to write during init.
|
|
@@ -851,9 +832,7 @@ export function getExampleWorkflowFileName(packageJson) {
|
|
|
851
832
|
* @returns The runner file name to create
|
|
852
833
|
*/
|
|
853
834
|
export function getRunFileName(packageJson) {
|
|
854
|
-
|
|
855
|
-
const extension = path.extname(configFileName) || ".js";
|
|
856
|
-
return `hello-world.run${extension}`;
|
|
835
|
+
return `hello-world.run${getScriptExtension(packageJson)}`;
|
|
857
836
|
}
|
|
858
837
|
/**
|
|
859
838
|
* Determine the client filename to write during init.
|
|
@@ -861,9 +840,7 @@ export function getRunFileName(packageJson) {
|
|
|
861
840
|
* @returns The client file name to create
|
|
862
841
|
*/
|
|
863
842
|
export function getClientFileName(packageJson) {
|
|
864
|
-
|
|
865
|
-
const extension = path.extname(configFileName) || ".js";
|
|
866
|
-
return `client${extension}`;
|
|
843
|
+
return `client${getScriptExtension(packageJson)}`;
|
|
867
844
|
}
|
|
868
845
|
/**
|
|
869
846
|
* Check whether a dependency is declared in package.json.
|
|
@@ -904,42 +881,18 @@ function warnIfMissingTsconfig(packageJson) {
|
|
|
904
881
|
}
|
|
905
882
|
}
|
|
906
883
|
/**
|
|
907
|
-
* Ensure a specific environment variable exists in a .env file. Creates the
|
|
908
|
-
* doesn't exist, appends the variable if not present.
|
|
884
|
+
* Ensure a specific environment variable exists in a .env file. Creates the
|
|
885
|
+
* file if it doesn't exist, appends the variable if not present.
|
|
909
886
|
* @param envPath - Path to the .env file
|
|
910
887
|
* @param key - The environment variable key (e.g. "OPENWORKFLOW_POSTGRES_URL")
|
|
911
888
|
* @param value - The default value for the environment variable
|
|
912
|
-
* @returns
|
|
889
|
+
* @returns Whether the entry was appended
|
|
913
890
|
*/
|
|
914
891
|
function ensureEnvEntry(envPath, key, value) {
|
|
915
|
-
|
|
916
|
-
let content = "";
|
|
917
|
-
if (fileExists) {
|
|
918
|
-
content = readFileSync(envPath, "utf8");
|
|
919
|
-
}
|
|
920
|
-
// check if key already exists (looking for KEY= at start of line)
|
|
921
|
-
const lines = content.split("\n");
|
|
922
|
-
const hasKey = lines.some((line) => {
|
|
892
|
+
return appendLineIfMissing(envPath, `${key}=${value}`, (line) => {
|
|
923
893
|
const trimmed = line.trim();
|
|
924
894
|
return trimmed.startsWith(`${key}=`) || trimmed.startsWith(`${key} =`);
|
|
925
895
|
});
|
|
926
|
-
if (hasKey) {
|
|
927
|
-
return { added: false, created: false };
|
|
928
|
-
}
|
|
929
|
-
// add entry to .env
|
|
930
|
-
let newContent;
|
|
931
|
-
const envEntry = `${key}=${value}`;
|
|
932
|
-
if (content === "") {
|
|
933
|
-
newContent = `${envEntry}\n`;
|
|
934
|
-
}
|
|
935
|
-
else if (content.endsWith("\n")) {
|
|
936
|
-
newContent = `${content}${envEntry}\n`;
|
|
937
|
-
}
|
|
938
|
-
else {
|
|
939
|
-
newContent = `${content}\n${envEntry}\n`;
|
|
940
|
-
}
|
|
941
|
-
writeFileSync(envPath, newContent, "utf8");
|
|
942
|
-
return { added: true, created: !fileExists };
|
|
943
896
|
}
|
|
944
897
|
/**
|
|
945
898
|
* Validate a numeric option is a positive integer.
|
package/dist/config.js
CHANGED
|
@@ -12,7 +12,7 @@ export function defineConfig(config) {
|
|
|
12
12
|
}
|
|
13
13
|
const CONFIG_NAME = "openworkflow.config";
|
|
14
14
|
const CONFIG_EXTENSIONS = ["ts", "mts", "cts", "js", "mjs", "cjs"];
|
|
15
|
-
const jiti = createJiti(import.meta.url);
|
|
15
|
+
const jiti = createJiti(import.meta.url, { tryNative: false }); // bun compatibility
|
|
16
16
|
/**
|
|
17
17
|
* Load OpenWorkflow config from an explicit path.
|
|
18
18
|
* @param configPath - Explicit config file path
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openworkflow/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
"prepublishOnly": "npm run build"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@clack/prompts": "^1.0
|
|
31
|
-
"commander": "^
|
|
30
|
+
"@clack/prompts": "^1.7.0",
|
|
31
|
+
"commander": "^15.0.0",
|
|
32
32
|
"consola": "^3.4.2",
|
|
33
|
-
"dotenv": "^17.
|
|
34
|
-
"jiti": "^2.
|
|
35
|
-
"nypm": "^0.6.
|
|
33
|
+
"dotenv": "^17.4.2",
|
|
34
|
+
"jiti": "^2.7.0",
|
|
35
|
+
"nypm": "^0.6.8"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"openworkflow": "*",
|
|
39
39
|
"vitest": "^4.0.18"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"openworkflow": "^0.6.0 || ^0.7.0 || ^0.8.0"
|
|
42
|
+
"openworkflow": "^0.6.0 || ^0.7.0 || ^0.8.0 || ^0.9.0"
|
|
43
43
|
}
|
|
44
44
|
}
|