feat(format): add check and fix workflows
This commit is contained in:
+104
-144
@@ -1,13 +1,107 @@
|
||||
import * as plugins from "./plugins.js";
|
||||
import * as paths from "./paths.js";
|
||||
import { GitzoneConfig } from "./classes.gitzoneconfig.js";
|
||||
import { getRawCliMode } from "./helpers.climode.js";
|
||||
import {
|
||||
getProcessUserArgv,
|
||||
getRawCliMode,
|
||||
parseCliArgv,
|
||||
} from "./helpers.climode.js";
|
||||
import { commitinfo } from "./00_commitinfo_data.js";
|
||||
|
||||
const gitzoneSmartcli = new plugins.smartcli.Smartcli();
|
||||
const runParsedCommand = async (argvArg: any): Promise<void> => {
|
||||
const command = argvArg._?.[0];
|
||||
|
||||
switch (command) {
|
||||
case undefined:
|
||||
case "help": {
|
||||
const modStandard = await import("./mod_standard/index.js");
|
||||
await modStandard.run(argvArg);
|
||||
break;
|
||||
}
|
||||
case "commit": {
|
||||
const modCommit = await import("./mod_commit/index.js");
|
||||
await modCommit.run(argvArg);
|
||||
break;
|
||||
}
|
||||
case "release": {
|
||||
const modRelease = await import("./mod_release/index.js");
|
||||
await modRelease.run(argvArg);
|
||||
break;
|
||||
}
|
||||
case "deprecate": {
|
||||
const modDeprecate = await import("./mod_deprecate/index.js");
|
||||
await modDeprecate.run();
|
||||
break;
|
||||
}
|
||||
case "docker": {
|
||||
const modDocker = await import("./mod_docker/index.js");
|
||||
await modDocker.run(argvArg);
|
||||
break;
|
||||
}
|
||||
case "format": {
|
||||
const modFormat = await import("./mod_format/index.js");
|
||||
await modFormat.run({
|
||||
...argvArg,
|
||||
write: argvArg.write || argvArg.w,
|
||||
dryRun: argvArg["dry-run"],
|
||||
yes: argvArg.yes || argvArg.y,
|
||||
planOnly: argvArg["plan-only"] || argvArg.planOnly,
|
||||
savePlan: argvArg["save-plan"] || argvArg.savePlan,
|
||||
fromPlan: argvArg["from-plan"] || argvArg.fromPlan,
|
||||
detailed: argvArg.detailed,
|
||||
interactive: argvArg.interactive !== false,
|
||||
verbose: argvArg.verbose,
|
||||
diff: argvArg.diff,
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "meta": {
|
||||
const modMeta = await import("./mod_meta/index.js");
|
||||
await modMeta.run(argvArg);
|
||||
break;
|
||||
}
|
||||
case "open": {
|
||||
const modOpen = await import("./mod_open/index.js");
|
||||
await modOpen.run(argvArg);
|
||||
break;
|
||||
}
|
||||
case "template": {
|
||||
const modTemplate = await import("./mod_template/index.js");
|
||||
await modTemplate.run(argvArg);
|
||||
break;
|
||||
}
|
||||
case "start": {
|
||||
const modStart = await import("./mod_start/index.js");
|
||||
await modStart.run(argvArg);
|
||||
break;
|
||||
}
|
||||
case "helpers": {
|
||||
const modHelpers = await import("./mod_helpers/index.js");
|
||||
await modHelpers.run(argvArg);
|
||||
break;
|
||||
}
|
||||
case "tools": {
|
||||
const modTools = await import("./mod_tools/index.js");
|
||||
await modTools.run(argvArg);
|
||||
break;
|
||||
}
|
||||
case "config": {
|
||||
const modConfig = await import("./mod_config/index.js");
|
||||
await modConfig.run(argvArg);
|
||||
break;
|
||||
}
|
||||
case "services": {
|
||||
const modServices = await import("./mod_services/index.js");
|
||||
await modServices.run(argvArg);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
const modStandard = await import("./mod_standard/index.js");
|
||||
await modStandard.run(argvArg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export let run = async () => {
|
||||
const done = plugins.smartpromise.defer();
|
||||
const rawCliMode = await getRawCliMode();
|
||||
|
||||
// get packageInfo
|
||||
@@ -34,144 +128,10 @@ export let run = async () => {
|
||||
if (rawCliMode.output === "human") {
|
||||
console.log("---------------------------------------------");
|
||||
}
|
||||
gitzoneSmartcli.addVersion(packageVersion);
|
||||
|
||||
// ======> Standard task <======
|
||||
|
||||
/**
|
||||
* standard task
|
||||
*/
|
||||
gitzoneSmartcli.standardCommand().subscribe(async (argvArg) => {
|
||||
const modStandard = await import("./mod_standard/index.js");
|
||||
await modStandard.run(argvArg);
|
||||
});
|
||||
|
||||
gitzoneSmartcli.addCommand("help").subscribe(async (argvArg) => {
|
||||
const modStandard = await import("./mod_standard/index.js");
|
||||
await modStandard.run(argvArg);
|
||||
});
|
||||
|
||||
// ======> Specific tasks <======
|
||||
|
||||
/**
|
||||
* commit something
|
||||
*/
|
||||
gitzoneSmartcli.addCommand("commit").subscribe(async (argvArg) => {
|
||||
const modCommit = await import("./mod_commit/index.js");
|
||||
await modCommit.run(argvArg);
|
||||
});
|
||||
|
||||
/**
|
||||
* create a release from pending changelog entries
|
||||
*/
|
||||
gitzoneSmartcli.addCommand("release").subscribe(async (argvArg) => {
|
||||
const modRelease = await import("./mod_release/index.js");
|
||||
await modRelease.run(argvArg);
|
||||
});
|
||||
|
||||
/**
|
||||
* deprecate a package on npm
|
||||
*/
|
||||
gitzoneSmartcli.addCommand("deprecate").subscribe(async (argvArg) => {
|
||||
const modDeprecate = await import("./mod_deprecate/index.js");
|
||||
await modDeprecate.run();
|
||||
});
|
||||
|
||||
/**
|
||||
* docker
|
||||
*/
|
||||
gitzoneSmartcli.addCommand("docker").subscribe(async (argvArg) => {
|
||||
const modDocker = await import("./mod_docker/index.js");
|
||||
await modDocker.run(argvArg);
|
||||
});
|
||||
|
||||
/**
|
||||
* Update all files that comply with the gitzone standard
|
||||
*/
|
||||
gitzoneSmartcli.addCommand("format").subscribe(async (argvArg) => {
|
||||
const config = GitzoneConfig.fromCwd();
|
||||
const modFormat = await import("./mod_format/index.js");
|
||||
|
||||
// Handle format with options
|
||||
// Default is dry-mode, use --write/-w to apply changes
|
||||
await modFormat.run({
|
||||
...argvArg,
|
||||
write: argvArg.write || argvArg.w,
|
||||
dryRun: argvArg["dry-run"],
|
||||
yes: argvArg.yes,
|
||||
planOnly: argvArg["plan-only"],
|
||||
savePlan: argvArg["save-plan"],
|
||||
fromPlan: argvArg["from-plan"],
|
||||
detailed: argvArg.detailed,
|
||||
interactive: argvArg.interactive !== false,
|
||||
verbose: argvArg.verbose,
|
||||
diff: argvArg.diff,
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* run meta commands
|
||||
*/
|
||||
gitzoneSmartcli.addCommand("meta").subscribe(async (argvArg) => {
|
||||
const config = GitzoneConfig.fromCwd();
|
||||
const modMeta = await import("./mod_meta/index.js");
|
||||
modMeta.run(argvArg);
|
||||
});
|
||||
|
||||
/**
|
||||
* open assets
|
||||
*/
|
||||
gitzoneSmartcli.addCommand("open").subscribe(async (argvArg) => {
|
||||
const modOpen = await import("./mod_open/index.js");
|
||||
modOpen.run(argvArg);
|
||||
});
|
||||
|
||||
/**
|
||||
* add a readme to a project
|
||||
*/
|
||||
gitzoneSmartcli.addCommand("template").subscribe(async (argvArg) => {
|
||||
const modTemplate = await import("./mod_template/index.js");
|
||||
modTemplate.run(argvArg);
|
||||
});
|
||||
|
||||
/**
|
||||
* start working on a project
|
||||
*/
|
||||
gitzoneSmartcli.addCommand("start").subscribe(async (argvArg) => {
|
||||
const modTemplate = await import("./mod_start/index.js");
|
||||
modTemplate.run(argvArg);
|
||||
});
|
||||
|
||||
gitzoneSmartcli.addCommand("helpers").subscribe(async (argvArg) => {
|
||||
const modHelpers = await import("./mod_helpers/index.js");
|
||||
modHelpers.run(argvArg);
|
||||
});
|
||||
|
||||
/**
|
||||
* manage the global @git.zone toolchain
|
||||
*/
|
||||
gitzoneSmartcli.addCommand("tools").subscribe(async (argvArg) => {
|
||||
const modTools = await import("./mod_tools/index.js");
|
||||
await modTools.run(argvArg);
|
||||
});
|
||||
|
||||
/**
|
||||
* manage release configuration
|
||||
*/
|
||||
gitzoneSmartcli.addCommand("config").subscribe(async (argvArg) => {
|
||||
const modConfig = await import("./mod_config/index.js");
|
||||
await modConfig.run(argvArg);
|
||||
});
|
||||
|
||||
/**
|
||||
* manage development services (MongoDB, S3/MinIO)
|
||||
*/
|
||||
gitzoneSmartcli.addCommand("services").subscribe(async (argvArg) => {
|
||||
const modServices = await import("./mod_services/index.js");
|
||||
await modServices.run(argvArg);
|
||||
});
|
||||
|
||||
// start parsing of the cli
|
||||
gitzoneSmartcli.startParse();
|
||||
return await done.promise;
|
||||
const argvArg = parseCliArgv(getProcessUserArgv());
|
||||
if (argvArg.v || argvArg.version) {
|
||||
console.log(packageVersion);
|
||||
return;
|
||||
}
|
||||
await runParsedCommand(argvArg);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user