-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: move build to tsup * feat: new template * refactor: remove listr2 and execa * feat: init new script * refactor: move plugin structure * feat: add new entry * refactor: further adjustments * chore: add changeset * fix: small fixes * feat: init copy function * feat: use create-svelte * feat: update dev deps * fix: deepmerge * refactor: remove plugin template * feat: copy files * fix: last updates for package.json * refactor: conditionally adjust plugin * refactor: remove unusded code * chore: package for distribution * feat: parse args * refactor: remove command-line-args * Update packages/create-webstone-app/templates/plugin-structure/build-cli.js Co-authored-by: Mike Nikles <[email protected]> * test: add tests * test: add new tests * test: remove old tests * test: add test --------- Co-authored-by: Mike Nikles <[email protected]>
- Loading branch information
1 parent
ec0ea0e
commit 01f44e5
Showing
52 changed files
with
818 additions
and
1,648 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"create-webstone-app": minor | ||
--- | ||
|
||
refactor create-webstone-app to use new flow & new plugin template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"terminal.integrated.profiles.osx": { | ||
"devboxCompatibleShell": { | ||
"path": "/bin/zsh", | ||
"args": [] | ||
} | ||
}, | ||
"terminal.integrated.defaultProfile.osx": "devboxCompatibleShell" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/usr/bin/env node | ||
import("./dist/index.js"); | ||
import("./dist/bin.js"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,25 @@ | ||
import esbuild from "esbuild"; | ||
import { nodeExternalsPlugin } from "esbuild-node-externals"; | ||
|
||
/** | ||
* @type {Object.<string, esbuild.BuildOptions>} | ||
*/ | ||
const config = { | ||
format: "esm", | ||
target: "esnext", | ||
plugins: [nodeExternalsPlugin()], | ||
banner: { | ||
js: "#!/usr/bin/env node", | ||
}, | ||
bundle: true, | ||
entryPoints: ["./src/index.ts"], | ||
logLevel: "info", | ||
minify: true, | ||
outfile: "./dist/index.js", | ||
platform: "node", | ||
}; | ||
import { defineConfig, build } from "tsup"; | ||
|
||
/** | ||
* @type {"build" | "dev"} | ||
*/ | ||
|
||
const mode = process.argv[2]; | ||
if (!mode) { | ||
console.error("Usage: node ./scripts/esbuild.js build|dev"); | ||
|
||
// check if mode is valid | ||
if (!["build", "dev"].includes(mode)) { | ||
console.log("Usage: node ./scripts/build.js build|dev"); | ||
process.exit(1); | ||
} | ||
|
||
switch (mode) { | ||
case "build": | ||
await esbuild.build(config).catch(() => process.exit(1)); | ||
break; | ||
case "dev": { | ||
const context = await esbuild.context(config).catch(() => process.exit(1)); | ||
await context.watch(); | ||
break; | ||
} | ||
} | ||
const config = defineConfig({ | ||
entry: ["src/index.ts", "src/bin.ts"], | ||
target: "esnext", | ||
format: "esm", | ||
treeshake: true, | ||
minify: true, | ||
dts: true, | ||
watch: mode === "dev" ? ["src"] : false, | ||
}); | ||
|
||
await build(config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import fs from "fs-extra"; | ||
import chalk from "chalk"; | ||
import enquirer from "enquirer"; | ||
import { displayNextSteps, displayWelcome } from "./helpers"; | ||
import { createWebstone } from "./index"; | ||
import { parseArgs } from "node:util"; | ||
|
||
// argparsing | ||
const { values: argValues } = parseArgs({ | ||
allowPositionals: true, | ||
options: { | ||
type: { | ||
type: "string", | ||
alias: "t", | ||
}, | ||
"extend-cli": { | ||
type: "boolean", | ||
}, | ||
}, | ||
}); | ||
|
||
let extendCLI = argValues["extend-cli"] || false; | ||
let type: "app" | "plugin" | null = null; | ||
if (argValues.type && ["app", "plugin"].includes(argValues.type)) { | ||
type = argValues.type as "app" | "plugin"; | ||
} | ||
|
||
const { version } = JSON.parse( | ||
fs.readFileSync(new URL("../package.json", import.meta.url), "utf-8"), | ||
); | ||
|
||
let cwd = | ||
process.argv[2] && !process.argv[2].startsWith("--") ? process.argv[2] : "."; | ||
|
||
displayWelcome(); | ||
console.log(chalk.bold(`create-webstone v${version}`)); | ||
|
||
if (cwd === ".") { | ||
const dir: { dir: string } = await enquirer.prompt({ | ||
type: "text", | ||
name: "dir", | ||
message: | ||
"Where should we create your project? (Hit enter to use current directory)", | ||
initial: ".", | ||
}); | ||
|
||
cwd = dir.dir; | ||
} | ||
|
||
if (fs.existsSync(cwd)) { | ||
if (fs.readdirSync(cwd).length > 0) { | ||
const forceCreate: { forceCreate: boolean } = await enquirer.prompt({ | ||
type: "confirm", | ||
name: "forceCreate", | ||
message: `The ./${cwd} directory is not empty. Do you want to continue?`, | ||
initial: false, | ||
}); | ||
|
||
if (!forceCreate.forceCreate) { | ||
console.log( | ||
chalk.red( | ||
`Exiting, please empty the ./${cwd} directory or choose a different one to create the Webstone app.`, | ||
), | ||
); | ||
process.exit(1); | ||
} | ||
} | ||
} | ||
|
||
if (!type) { | ||
const promptType: { type: "Webstone App" | "Webstone Plugin" } = | ||
await enquirer.prompt({ | ||
type: "select", | ||
name: "type", | ||
message: "What type of Webstone project do you want to create?", | ||
choices: ["Webstone App", "Webstone Plugin"], | ||
}); | ||
|
||
const typeMap = { | ||
"Webstone App": "app", | ||
"Webstone Plugin": "plugin", | ||
} as const; | ||
|
||
type = typeMap[promptType.type]; | ||
} | ||
|
||
if (type === "plugin" && !extendCLI) { | ||
const extendCLIAnswer: { extendCLI: boolean } = await enquirer.prompt({ | ||
type: "confirm", | ||
name: "extendCLI", | ||
message: "Does your plugin extend the Webstone CLI?", | ||
initial: false, | ||
}); | ||
extendCLI = extendCLIAnswer.extendCLI; | ||
} | ||
|
||
await createWebstone(cwd, { type, extendCLI }); | ||
|
||
displayNextSteps(cwd); |
Oops, something went wrong.