@stringtale/cli
Advanced tools
Comparing version 0.6.0 to 0.6.1
# @stringtale/cli | ||
## 0.6.1 | ||
### Patch Changes | ||
- 9ad5767: Fix stdout being all on one line | ||
- ad34057: Fix codemod giving the wrong error when looking for the config file. | ||
## 0.6.0 | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "@stringtale/cli", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
import { toValue } from "@stringtale/node" | ||
import { Command, Option } from "clipanion" | ||
import { CONFIG_FILE } from "config/const" | ||
import fs from "fs" | ||
@@ -33,4 +34,7 @@ import { glob } from "glob" | ||
toValue({ | ||
name: "global.warnings.noConfig", | ||
value: "No tsconfig.json found in current directory", | ||
name: "global.warnings.noStringtaleConfig", | ||
value: "No {configFile} found in current directory. Aborting.", | ||
format: { | ||
configFile: CONFIG_FILE, | ||
}, | ||
}) | ||
@@ -43,3 +47,3 @@ ) | ||
toValue({ | ||
name: "global.warnings.noConfig", | ||
name: "global.warnings.noFilesFound", | ||
value: "No files found in configuration", | ||
@@ -46,0 +50,0 @@ }) |
@@ -46,3 +46,2 @@ import { toValue } from "@stringtale/node" | ||
async execute() { | ||
await loadNodeFetch() | ||
@@ -59,3 +58,3 @@ | ||
name: "init.alreadyInitialized", | ||
value: "Project already initialized" | ||
value: "Project already initialized", | ||
})}\n` | ||
@@ -80,3 +79,3 @@ ) | ||
name: "init.language", | ||
value: "Which language are you using?" | ||
value: "Which language are you using?", | ||
}), | ||
@@ -99,3 +98,3 @@ required: true, | ||
name: "init.project", | ||
value: "Which Stringtale project would you like to use?" | ||
value: "Which Stringtale project would you like to use?", | ||
}), | ||
@@ -119,3 +118,3 @@ required: true, | ||
name: "init.framework", | ||
value: "Which backend framework are you using?" | ||
value: "Which backend framework are you using?", | ||
}), | ||
@@ -135,3 +134,3 @@ required: true, | ||
stdout.write("Generating config stringtale.config.json") | ||
stdout.write(`Generating config ${CONFIG_FILE}\n`) | ||
await fs.writeJSON( | ||
@@ -162,3 +161,3 @@ localConfigPath, | ||
name: "init.nextConfigNotFound", | ||
value: "next.config.js not found" | ||
value: "next.config.js not found", | ||
})}\n` | ||
@@ -180,3 +179,4 @@ ) | ||
name: "init.configFile", | ||
value: "Couldn't find your next.config.js file. Which next.config.js file would you like to use?" | ||
value: | ||
"Couldn't find your next.config.js file. Which next.config.js file would you like to use?", | ||
}), | ||
@@ -205,3 +205,3 @@ required: true, | ||
stdout.write("Detecting App directory or Pages router...") | ||
stdout.write("Detecting App directory or Pages router...\n") | ||
@@ -230,7 +230,12 @@ if (fs.existsSync(path.resolve(nextRoot, "src/app/"))) { | ||
name: `appOrPages`, | ||
message: toValue({ name: "init.appOrPages", value: "Both app and pages directories found. Which directory would you like to use?" }), | ||
message: toValue({ | ||
name: "init.appOrPages", | ||
value: | ||
"Both app and pages directories found. Which directory would you like to use?", | ||
}), | ||
required: true, | ||
onCancel: () => process.exit(130), | ||
// @ts-ignore | ||
stdin, stdout, | ||
stdin, | ||
stdout, | ||
choices: [ | ||
@@ -240,3 +245,3 @@ { name: "app", message: "App", value: "app" }, | ||
], | ||
} | ||
}, | ||
]) | ||
@@ -251,6 +256,6 @@ if (appOrPages === "app") { | ||
if (isAppDir) { | ||
stdout.write("App router detected.") | ||
stdout.write("App router detected.\n") | ||
apiPath = apiAppPath | ||
} else if (isPagesDir) { | ||
stdout.write("Pages router detected.") | ||
stdout.write("Pages router detected.\n") | ||
apiPath = apiPagesPath | ||
@@ -265,3 +270,3 @@ } | ||
const apiRouteFilename = `stringtale.${ext}` | ||
stdout.write(`Generating ${apiPath}/${apiRouteFilename}.${ext}.`) | ||
stdout.write(`Generating ${apiPath}/${apiRouteFilename}.${ext}.\n`) | ||
await fs.writeFile( | ||
@@ -277,3 +282,3 @@ path.resolve(apiPath, apiRouteFilename), | ||
POST | ||
}` | ||
}\n` | ||
) | ||
@@ -283,3 +288,3 @@ } else { | ||
const apiRouteFilename = `stringtale.${ext}` | ||
stdout.write(`Generating ${apiPath}/${apiRouteFilename}.${ext}.`) | ||
stdout.write(`Generating ${apiPath}/${apiRouteFilename}.${ext}.\n`) | ||
await fs.writeFile( | ||
@@ -294,3 +299,3 @@ path.resolve(apiPath, apiRouteFilename), | ||
} | ||
stdout.write(`Installing modules @stringtale/react @stringtale/next.`) | ||
stdout.write(`Installing modules @stringtale/react @stringtale/next.\n`) | ||
await installModules(nextRoot, `@stringtale/react @stringtale/next`) | ||
@@ -300,3 +305,5 @@ | ||
} else { | ||
stdout.write(`Installing modules @stringtale/react @stringtale/express.`) | ||
stdout.write( | ||
`Installing modules @stringtale/react @stringtale/express.\n` | ||
) | ||
await installModules(root, `@stringtale/react @stringtale/express`) | ||
@@ -307,3 +314,3 @@ | ||
) | ||
stdout.write(`import express from 'express' | ||
stdout.write(`import express from 'expres\ns' | ||
import { setupRoute } from "@stringtale/express" | ||
@@ -314,3 +321,3 @@ const app = express() | ||
apiKey: process.env.STRINGTALE_API_KEY${language === "ts" ? "!" : ""} | ||
}))`) | ||
}))\n`) | ||
@@ -320,3 +327,3 @@ stdout.write( | ||
) | ||
stdout.write(`import { StringtaleProvider } from "@stringtale/react" | ||
stdout.write(`import { StringtaleProvider } from "@stringtale/reac\nt" | ||
import "@stringtale/react/styles.css" | ||
@@ -332,7 +339,9 @@ | ||
export default App`) | ||
export default App\n`) | ||
} | ||
stdout.write(`${toValue({ name: "init.success", value: "Project initialized" })}\n`) | ||
stdout.write( | ||
`${toValue({ name: "init.success", value: "Project initialized" })}\n` | ||
) | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
5409540
47600