From 7f6451af4330a53641913bf2f7933b6df5c29ed7 Mon Sep 17 00:00:00 2001 From: Damian Reeves <957246+DamianReeves@users.noreply.github.com> Date: Wed, 4 Sep 2024 23:14:13 -0500 Subject: [PATCH] Add a package.json to allow treating cli as CommonJS module --- cli/package.json | 3 +++ gulpfile.js | 16 ++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 cli/package.json diff --git a/cli/package.json b/cli/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/cli/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/gulpfile.js b/gulpfile.js index 9e2bc8a40..a3a2f5a2c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -117,7 +117,7 @@ const buildCLI2 = makeCLI2 ) -const buildMorphirAPI2 = async () => { +export const buildMorphirAPI2 = async () => { try { await morphirElmMakeRunOldCli('.', './morphir-ir.json', { typesOnly: true }) await morphirElmGen('./morphir-ir.json', './lib/generated', 'TypeScript') @@ -147,7 +147,7 @@ const build = function morphirElmMake(projectDir, outputPath, options = {}) { - args = ['./cli/morphir-elm.js', 'make', '-p', projectDir, '-o', outputPath] + let args = ['./cli/morphir-elm.js', 'make', '-p', projectDir, '-o', outputPath] if (options.typesOnly) { args.push('--types-only') } @@ -156,7 +156,7 @@ function morphirElmMake(projectDir, outputPath, options = {}) { } function morphirElmMakeRunOldCli(projectDir, outputPath, options = {}) { - args = ['./cli/morphir-elm.js', 'make', '-f', '-p', projectDir, '-o', outputPath] + let args = ['./cli/morphir-elm.js', 'make', '-f', '-p', projectDir, '-o', outputPath] if (options.typesOnly) { args.push('--types-only') } @@ -165,7 +165,7 @@ function morphirElmMakeRunOldCli(projectDir, outputPath, options = {}) { } function morphirElmMake2(projectDir, outputPath, options = {}) { - args = ['./cli2/lib/morphir.js', 'make', '-p', projectDir, '-o', outputPath] + let args = ['./cli2/lib/morphir.js', 'make', '-p', projectDir, '-o', outputPath] if (options.typesOnly) { args.push('--types-only') } @@ -175,7 +175,7 @@ function morphirElmMake2(projectDir, outputPath, options = {}) { // Generate the IR for the Json Schema mdel function morphirElmMakeJsonSchema(projectDir, outputPath, options = {}) { - args = ['./cli2/lib/morphir.js', 'make', '-p', projectDir, '-o', outputPath] + let args = ['./cli2/lib/morphir.js', 'make', '-p', projectDir, '-o', outputPath] if (options.typesOnly) { args.push('--types-only') } @@ -184,14 +184,14 @@ function morphirElmMakeJsonSchema(projectDir, outputPath, options = {}) { } function morphirElmGen(inputPath, outputDir, target) { - args = ['./cli/morphir-elm.js', 'gen', '-i', inputPath, '-o', outputDir, '-t', target] + let args = ['./cli/morphir-elm.js', 'gen', '-i', inputPath, '-o', outputDir, '-t', target] console.log("Running: " + args.join(' ')); return execa('node', args, { stdio }) } // Test the json-schema-gen command. async function morphirJsonSchemaGen(inputPath, outputDir, target) { - args = ['./cli2/lib/morphir-json-schema-gen.js', 'json-schema-gen', '-i', inputPath, '-o', outputDir, '-t', target] + let args = ['./cli2/lib/morphir-json-schema-gen.js', 'json-schema-gen', '-i', inputPath, '-o', outputDir, '-t', target] console.log("Running: " + args.join(' ')); try { await execa('node', args, { stdio }) @@ -208,7 +208,7 @@ function morphirDockerize(projectDir, options = {}) { let projectDirFlag = '-p' let overwriteDockerfileFlag = '-f' let projectDirArgs = [projectDirFlag, projectDir] - args = [ + let args = [ funcLocation, command, projectDirArgs.join(' '),