Skip to content

Commit

Permalink
Add a package.json to allow treating cli as CommonJS module
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianReeves committed Sep 5, 2024
1 parent 079646a commit 7f6451a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
16 changes: 8 additions & 8 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')
}
Expand All @@ -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')
}
Expand All @@ -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')
}
Expand All @@ -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')
}
Expand All @@ -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 })
Expand All @@ -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(' '),
Expand Down

0 comments on commit 7f6451a

Please sign in to comment.