@godspeedsystems/godspeed
Version:
Godspeed CLI
86 lines • 3.67 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fsExtras = require("fs-extra");
const path_1 = __importDefault(require("path"));
// import interactiveMode from "../../utils/interactiveMode";
// import {
// buildContainers,
// getComposeOptions,
// prepareToStartContainers,
// } from "../../utils/dockerUtility";
// import checkPrerequisite from "../../utils/checkPrerequisite";
const index_1 = require("../../utils/index");
const utils_1 = require("../../utils");
const utils_2 = require("../../utils");
const utils_3 = require("../../utils");
const utils_4 = require("../../utils");
const signale_1 = require("../../utils/signale");
/**
* options = {
* --from-template: "path or git repo of template",
* --with-example: "wether to copy examples or not",
* }
* */
async function create(projectName, options, cliVersion) {
// await checkPrerequisite();
const projectDirPath = path_1.default.resolve(process.cwd(), projectName);
await (0, index_1.validateAndCreateProjectDirectory)(projectDirPath);
// directory is created
let godspeedOptions;
if (options.fromTemplate) {
await (0, utils_1.copyingLocalTemplate)(projectDirPath, options.fromTemplate);
}
else {
await (0, utils_2.cloneProjectTemplate)(projectDirPath);
}
godspeedOptions = await (0, utils_3.generateFromExamples)(projectDirPath, options.fromExample);
// if (!godspeedOptions) {
// godspeedOptions = await interactiveMode({}, false);
// }
godspeedOptions = godspeedOptions;
let timestamp = new Date().toISOString();
godspeedOptions.projectName = projectName;
godspeedOptions.meta = {
createTimestamp: timestamp,
lastUpdateTimestamp: timestamp,
cliVersionWhileCreation: cliVersion,
cliVersionWhileLastUpdate: cliVersion,
};
// by this time we have all things required to spin up the service and create project
// let's start the generation process
await (0, utils_4.generateProjectFromDotGodspeed)(projectName, projectDirPath, godspeedOptions, options.fromExample);
// removing .git folder in project folder.
const gitFilePath = path_1.default.join(process.cwd(), projectName, ".git");
fsExtras.removeSync(gitFilePath);
if (options.fromExample === 'mongo-as-prisma') {
await (0, index_1.installPackage)(projectDirPath, '@godspeedsystems/plugins-prisma-as-datastore');
}
await (0, index_1.installDependencies)(projectDirPath, projectName);
try {
// the NEW flow [without containers]
// const composeOptions = await getComposeOptions();
// if (composeOptions.composeOptions) {
// composeOptions.composeOptions.push(`${projectName}_devcontainer`);
// }
// composeOptions.cwd = path.resolve(projectDirPath, ".devcontainer");
// composeOptions.log = process.env.DEBUG ? Boolean(process.env.DEBUG) : false;
// // check if there are already running resources
// await prepareToStartContainers(projectName, composeOptions);
// await buildContainers(
// projectName,
// godspeedOptions,
// composeOptions,
// projectDirPath
// );
}
catch (error) {
signale_1.log.error(error);
fsExtras.rmSync(projectDirPath, { recursive: true });
process.exit(1);
}
}
exports.default = create;
//# sourceMappingURL=index.js.map