-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
init
,profile
,config
,`category…
…`,default, new app structure, functions and utils
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ out/ | |
|
||
# production | ||
build | ||
dist | ||
**/dist/** | ||
lib | ||
|
||
# misc | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,5 @@ export default merge(webpackBaseConfig, { | |
output: { | ||
path: PATHOUT | ||
} | ||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,15 @@ | ||
import CopyPlugin from "copy-webpack-plugin"; | ||
import { join, resolve } from "path"; | ||
import { merge } from "webpack-merge"; | ||
import WebpackConfig from "webpackrc/webpack.base.js"; | ||
|
||
export default merge(WebpackConfig, {}); | ||
const __dirname = resolve(); | ||
const PATHOUT = resolve(__dirname, "lib"); | ||
|
||
export default merge(WebpackConfig, { | ||
plugins: [ | ||
new CopyPlugin({ | ||
patterns: [{ from: resolve(__dirname, "./src/templates"), to: join(PATHOUT, "templates") }] | ||
}) | ||
] | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { merge } from "webpack-merge"; | ||
import WebpackConfigDev from "webpackrc/webpack.dev.js"; | ||
import WebpackConfigBasic from "./webpack.base.js"; | ||
|
||
export default merge(WebpackConfigDev, {}); | ||
export default merge(WebpackConfigDev, WebpackConfigBasic, {}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
import { resolve } from "path"; | ||
import { merge } from "webpack-merge"; | ||
import WebpackConfigBasic from "./webpack.base.js"; | ||
import WebpackConfigProd from "webpackrc/webpack.prod.js"; | ||
|
||
export default merge(WebpackConfigProd, {}); | ||
const __dirname = resolve(); | ||
const PATHOUT = resolve(__dirname, "dist"); | ||
|
||
export default merge(WebpackConfigProd, WebpackConfigBasic); |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { program } from "commander"; | ||
import * as prompter from "@clack/prompts"; | ||
import chalk from "chalk"; | ||
import logging from "@/utils/logging"; | ||
import { join } from "path"; | ||
import { config } from "@/function/config"; | ||
import { scanDir } from "@/function"; | ||
|
||
program | ||
.command("category") | ||
.description("Select category") | ||
.option("-D, --DEBUG", "DEBUG MODE") | ||
.action(({ DEBUG }) => { | ||
process.env.DEBUG = DEBUG ? "TRUE" : "FALSE"; | ||
|
||
const [state, setState] = config(); | ||
prompter | ||
.group({ | ||
intro: () => { | ||
prompter.intro(chalk.bgCyan(" Select Category ")); | ||
Check failure on line 20 in packages/myplop/src/cli/category.ts GitHub Actions / Continuous-Integration
Check failure on line 20 in packages/myplop/src/cli/category.ts GitHub Actions / Continuous-Integration
|
||
}, | ||
currentlyChecked: () => { | ||
prompter.note(`Currently selected Category:\n${state.category}`, chalk.bgBlue(" Info ")); | ||
Check failure on line 23 in packages/myplop/src/cli/category.ts GitHub Actions / Continuous-Integration
Check failure on line 23 in packages/myplop/src/cli/category.ts GitHub Actions / Continuous-Integration
|
||
}, | ||
selectedCategory: async () => { | ||
if (state.config === null) { | ||
prompter.cancel("You need to select config first."); | ||
process.exit(1); | ||
} | ||
if (state.profile === null) { | ||
prompter.cancel("You need to select profile first."); | ||
process.exit(1); | ||
} | ||
logging.debug("Category path: ", process.env.CONFIGPATH); | ||
|
||
const pathToScan = join(process.env.CONFIGPATH, "config", state.config, "profiles", state.profile); | ||
const Categorys = scanDir(pathToScan, "category"); | ||
|
||
logging.debug("Found Categorys:", Categorys); | ||
const selected = await prompter.select({ | ||
message: "Select Category", | ||
initialValue: state.category, | ||
options: Categorys.map(({ name }) => ({ label: name, value: name })) | ||
}); | ||
|
||
logging.debug("Selected Category: ", selected); | ||
if (prompter.isCancel(selected) || !selected) { | ||
prompter.cancel("Canceled!"); | ||
process.exit(0); | ||
} | ||
return selected; | ||
}, | ||
selecting: ({ results }) => { | ||
if (results.selectedCategory === state.category) return void 0; | ||
setState(e => ({ ...e, category: results.selectedCategory! })); | ||
logging.debug("Category state: ", state); | ||
}, | ||
outro: () => { | ||
prompter.outro(chalk.bgGreen(" Category Selected! ")); | ||
Check failure on line 59 in packages/myplop/src/cli/category.ts GitHub Actions / Continuous-Integration
Check failure on line 59 in packages/myplop/src/cli/category.ts GitHub Actions / Continuous-Integration
|
||
} | ||
}) | ||
.catch(e => { | ||
logging.error(e); | ||
process.exit(1); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { program } from "commander"; | ||
import * as prompter from "@clack/prompts"; | ||
import chalk from "chalk"; | ||
import logging from "@/utils/logging"; | ||
import { join } from "path"; | ||
import { config } from "@/function/config"; | ||
import { scanDir } from "@/function"; | ||
|
||
program | ||
.command("config") | ||
.description("Select config") | ||
.option("-D, --DEBUG", "DEBUG MODE") | ||
.action(({ DEBUG }) => { | ||
process.env.DEBUG = DEBUG ? "TRUE" : "FALSE"; | ||
|
||
const [state, setState] = config(); | ||
prompter | ||
.group({ | ||
intro: () => { | ||
prompter.intro(chalk.bgCyan(" Select config ")); | ||
}, | ||
currentlyChecked: () => { | ||
prompter.note(`Currently selected config:\n${state.config}`, chalk.bgBlue(" Info ")); | ||
}, | ||
selectedConfig: async () => { | ||
logging.debug("Config path: ", process.env.CONFIGPATH); | ||
const pathToScan = join(process.env.CONFIGPATH, "./config"); | ||
const configs = scanDir(pathToScan, "config"); | ||
logging.debug("Found Configs:", configs); | ||
const selected = await prompter.select({ | ||
message: "Select config", | ||
initialValue: state.config, | ||
options: configs.map(({ name }) => ({ label: name, value: name })) | ||
}); | ||
logging.debug("Selected config: ", selected); | ||
return selected; | ||
}, | ||
selecting: ({ results }) => { | ||
if (results.selectedConfig === state.config) return; | ||
setState(e => ({ ...e, config: results.selectedConfig!, profile: null, category: null })); | ||
logging.debug("Config state: ", state); | ||
}, | ||
outro: () => { | ||
prompter.outro(chalk.bgGreen(" Config Selected! ")); | ||
} | ||
}) | ||
.catch(e => { | ||
throw e; | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { program } from "commander"; | ||
import * as prompter from "@clack/prompts"; | ||
import chalk from "chalk"; | ||
import { config } from "@/function"; | ||
|
||
program.action(() => { | ||
const [state] = config(); | ||
|
||
prompter | ||
.group( | ||
{ | ||
intro: () => { | ||
prompter.intro(chalk.bgCyan(" MyPlop ")); | ||
}, | ||
selectAction: () => { | ||
if (state.config === null) { | ||
prompter.cancel("You need to select config first."); | ||
process.exit(1); | ||
} | ||
if (state.profile === null) { | ||
prompter.cancel("You need to select profile first."); | ||
process.exit(1); | ||
} | ||
if (state.category === null) { | ||
prompter.cancel("You need to select category first."); | ||
process.exit(1); | ||
} | ||
} | ||
}, | ||
{ | ||
onCancel: () => { | ||
console.log(chalk.bgRed("Canceled")); | ||
process.exit(0); | ||
} | ||
} | ||
) | ||
.catch(e => { | ||
throw e; | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export * from "./default"; | ||
export * from "./init"; | ||
export * from "./version"; | ||
export * from "./config"; | ||
export * from "./profile"; | ||
export * from "./category"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { program } from "commander"; | ||
import * as prompter from "@clack/prompts"; | ||
import chalk from "chalk"; | ||
|
||
program | ||
.command("init") | ||
.description("Initialize plopfile") | ||
.option("-D, --DEBUG", "output extra debugging (default: false)", false) | ||
.action(({ DEBUG }) => { | ||
process.env.DEBUG = `${DEBUG}`.toUpperCase(); | ||
|
||
prompter | ||
.group( | ||
{ | ||
intro: () => { | ||
prompter.intro(chalk.bgCyan(" Initializer ")); | ||
}, | ||
choice: async () => | ||
prompter.select({ | ||
message: "What do you want to initialize?", | ||
initialValue: "app", | ||
options: [ | ||
{ label: "App", value: "app", hint: "Initialize app - required to work app" }, | ||
{ label: "Config", value: "config" }, | ||
{ label: "Profile", value: "profile", hint: "Initialize profile at config" }, | ||
{ label: "Component", value: "component", hint: "Initialize component" } | ||
] | ||
}), | ||
outro: () => { | ||
prompter.outro(chalk.bgGreen("Choosed correctly!")); | ||
}, | ||
loadModule: async ({ results }) => { | ||
await import(/* webpackMode: "eager" */ `./options/${results.choice}`).catch(err => { | ||
console.error("Module not found - probably file with option doesnt exist.", err); | ||
process.exit(0); | ||
}); | ||
} | ||
}, | ||
{ | ||
onCancel: () => { | ||
console.log(chalk.red("Canceled.")); | ||
process.exit(0); | ||
} | ||
} | ||
) | ||
.catch(e => { | ||
throw e; | ||
}); | ||
}); |