diff --git a/.gitignore b/.gitignore index 5a745e8b..256116aa 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ npm-debug.log /components log.txt -.builda.yml +.builda.json .buildcomrc .nyc_output/ coverage/ diff --git a/builda/.builda.json b/builda/.builda.json deleted file mode 100644 index fdd86e30..00000000 --- a/builda/.builda.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "app": { - "name": "test" - }, - "commands": { - "atom": { - "type": "scaffold", - "outputPath": "./experiments/atom", - "use": "default-ts", - "substitute": {} - }, - "component": { - "type": "scaffold", - "outputPath": "./experiments/component", - "use": "default-ts", - "substitute": {} - }, - "test": { - "type": "scaffold", - "outputPath": "./experiments/test", - "use": "default-ts", - "substitute": {} - } - }, - "modules": { - "scaffold": { - "default-ts": "1.0.0" - } - } -} \ No newline at end of file diff --git a/builda/dist/data/arguments.json b/builda/dist/data/arguments.json index 6c210dae..34246a9f 100644 --- a/builda/dist/data/arguments.json +++ b/builda/dist/data/arguments.json @@ -1,26 +1,26 @@ { - "init": { - "description": "Initialises a new project", - "required": false, - "boolean": true - }, - "add": { - "description": "Adds a new builda module", - "required": false, - "type": "string" - }, - "migrate": { - "description": "Migrates a project to the latest version", - "required": false, - "boolean": true - }, - "manual": { - "description": "Bypasses the need for a config file", - "required": false, - "boolean": true, - "alias": [ - "cli", - "m" - ] - } + "init": { + "description": "Initialises a new project", + "required": false, + "boolean": true + }, + "add": { + "description": "Adds a new builda module", + "required": false, + "type": "string" + }, + "migrate": { + "description": "Migrates a project to the latest version", + "required": false, + "boolean": true + }, + "manual": { + "description": "Bypasses the need for a config file", + "required": false, + "boolean": true, + "alias": [ + "cli", + "m" + ] + } } diff --git a/builda/dist/data/questions.js b/builda/dist/data/questions.js index 69066fb9..16b149ca 100644 --- a/builda/dist/data/questions.js +++ b/builda/dist/data/questions.js @@ -43,7 +43,8 @@ exports.default = [ { type: 'checkbox', name: 'scaffoldSelection', - message: 'Select zero or more scaffold types you wish to use', + message: 'Select one or more scaffold types you wish to use', + default: ['component'], choices: [ 'component', 'atom', diff --git a/builda/dist/helpers/get-module.js b/builda/dist/helpers/get-module.js index 1dfff3ed..a708afd5 100644 --- a/builda/dist/helpers/get-module.js +++ b/builda/dist/helpers/get-module.js @@ -14,9 +14,8 @@ const moduleTypes = ['scaffold', 'prefab']; const getmodule = (name) => { if (config) { const moduleList = config.modules; - const moduleCategory = moduleTypes.find((category) => { var _a; return moduleList[category] && ((_a = moduleList === null || moduleList === void 0 ? void 0 : moduleList[category]) === null || _a === void 0 ? void 0 : _a[name]); }); - const path = `${globals_1.default.buildaDir}/modules/${moduleCategory}/${name}`; - console.log(path); + const moduleType = moduleTypes.find((type) => { var _a; return moduleList[type] && ((_a = moduleList === null || moduleList === void 0 ? void 0 : moduleList[type]) === null || _a === void 0 ? void 0 : _a[name]); }); + const path = `${globals_1.default.buildaDir}/modules/${moduleType}/${name}`; const registry = JSON.parse(fs_1.default.readFileSync(`${path}/registry.json`, 'utf8')); const files = registry.files.filter((file) => file !== 'registry.json'); return { diff --git a/builda/dist/helpers/get-substitutions.js b/builda/dist/helpers/get-substitutions.js new file mode 100644 index 00000000..a7ceeb1f --- /dev/null +++ b/builda/dist/helpers/get-substitutions.js @@ -0,0 +1,49 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getSubstitutions = void 0; +const throw_error_1 = __importDefault(require("./throw-error")); +const getSubstitutions = (commandList, argv) => { + const substitutions = []; + if (commandList.substitute) { + commandList.substitute.forEach((sub) => { + var _a; + // No substitution was provided but the config requires one + if (sub.required && !argv[sub.string]) { + (0, throw_error_1.default)(`"--${sub.string}" missing in arguments. This is required.\n`); + } + // User has not provided a substitution but the config has a default fallback value + if (sub.default && !argv[sub.string]) { + substitutions.push({ + replace: sub.string, + with: sub.default + }); + } + // User has provided the substitution argument + if (argv[sub.string]) { + const value = argv[sub.string] === true + ? '' + : argv[sub.string]; + // User has provided the substitution argument with no value + if (value === '') { + (0, throw_error_1.default)(`"--${sub.string}" requires a value`); + } + if (sub.valid && + value !== '' && + !((_a = sub.valid) === null || _a === void 0 ? void 0 : _a.includes(value))) { + (0, throw_error_1.default)(`\n"${value}" is not a valid ${sub.string}. Please use one of the following: \n - ${sub.valid.join(`\n - `)}\n`); + } + // The value provided is valid + substitutions.push({ + replace: sub.string, + with: argv[sub.string] + }); + } + }); + } + return substitutions; +}; +exports.getSubstitutions = getSubstitutions; +exports.default = exports.getSubstitutions; diff --git a/builda/dist/helpers/index.js b/builda/dist/helpers/index.js index 7939c91b..25037313 100644 --- a/builda/dist/helpers/index.js +++ b/builda/dist/helpers/index.js @@ -3,11 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.writeFile = exports.convertRegistryPathToUrl = exports.getRegistry = exports.randomWordGenerator = exports.createDir = exports.throwError = exports.askQuestion = exports.nameError = exports.printLogo = exports.printMessage = exports.skip = exports.getModule = exports.getConfigFile = exports.detectPathType = void 0; +exports.writeFile = exports.convertRegistryPathToUrl = exports.getRegistry = exports.randomWordGenerator = exports.createDir = exports.throwError = exports.askQuestion = exports.nameError = exports.printLogo = exports.printMessage = exports.skip = exports.getModule = exports.getSubstitutions = exports.getConfigFile = exports.detectPathType = void 0; var detect_path_type_1 = require("./detect-path-type"); Object.defineProperty(exports, "detectPathType", { enumerable: true, get: function () { return __importDefault(detect_path_type_1).default; } }); var get_config_file_1 = require("./get-config-file"); Object.defineProperty(exports, "getConfigFile", { enumerable: true, get: function () { return __importDefault(get_config_file_1).default; } }); +var get_substitutions_1 = require("./get-substitutions"); +Object.defineProperty(exports, "getSubstitutions", { enumerable: true, get: function () { return __importDefault(get_substitutions_1).default; } }); var get_module_1 = require("./get-module"); Object.defineProperty(exports, "getModule", { enumerable: true, get: function () { return __importDefault(get_module_1).default; } }); var skip_1 = require("./skip"); diff --git a/builda/dist/index.js b/builda/dist/index.js index fea7e0ea..2e287fe1 100644 --- a/builda/dist/index.js +++ b/builda/dist/index.js @@ -10,6 +10,7 @@ const helpers_1 = require("yargs/helpers"); const _helpers_1 = require("./helpers/index.js"); // import data const arguments_json_1 = __importDefault(require("./data/arguments.json")); +const globals_1 = __importDefault(require("./data/globals")); // import scripts const init_1 = __importDefault(require("./scripts/init")); const generate_commands_1 = __importDefault(require("./scripts/generate-commands")); @@ -17,95 +18,67 @@ const build_from_scaffold_1 = __importDefault(require("./scripts/build-from-scaf const add_module_1 = __importDefault(require("./scripts/add-module")); const args = (0, helpers_1.hideBin)(process.argv); const config = (0, _helpers_1.getConfigFile)(); +const { configFileName, websiteUrl } = globals_1.default; const parser = (0, yargs_1.default)(args) .usage('Usage: $0 [options]') .options(arguments_json_1.default) .help('h') .version() - .alias('h', 'help'); + .alias('h', 'help') + .epilogue(`For more information, visit ${websiteUrl}`); (0, _helpers_1.printLogo)(); const CREATE_CONFIG_QUESTION = { - message: 'Would you like to create a .builda config?', + message: `Would you like to create a ${configFileName} config?`, name: 'createConfig', type: 'confirm' }; (async () => { const argv = await parser.argv; - if (args.length === 0 && config) { - // No arguments were passed but a config file exists - (0, _helpers_1.printMessage)('No arguments provided.\r', 'danger'); - parser.showHelp(); + /** UNHAPPY PATHS */ + if (config) { + if (args.length === 0) { + // No arguments were passed but a config file exists + (0, _helpers_1.printMessage)('No arguments provided.\r', 'danger'); + parser.showHelp(); + return process.exit(0); + } + if (argv.init) { + (0, _helpers_1.printMessage)(`A ${configFileName} has been found. Please delete it before continuing.\r`, 'danger'); + return process.exit(0); + } } if ((args.length === 0 || !argv.manual) && !config) { - (0, _helpers_1.printMessage)('Builda config not detected.\r', 'danger'); + (0, _helpers_1.printMessage)(`No ${configFileName} found. Please run the 'init' command.\r`, 'danger'); // No arguments were passed but a config file does not exist return (0, _helpers_1.askQuestion)(CREATE_CONFIG_QUESTION).then(({ createConfig }) => { if (createConfig) { return (0, init_1.default)({}); } (0, _helpers_1.printMessage)('Process terminated due to user selection', 'error'); - return process.exit(1); + return process.exit(0); }); } - if (argv.init) - (0, init_1.default)({}); if (argv.manual) { (0, _helpers_1.printMessage)('Manual mode selected.\r', 'notice'); - return (0, _helpers_1.printMessage)('🛠 This route does not exist yet.\r', 'notice'); - } - if (argv._[0].toString() === 'add') { - const module = argv._[1].toString(); - return (0, add_module_1.default)({ path: module }); + (0, _helpers_1.printMessage)('🛠 This route does not exist yet.\r', 'notice'); + return process.exit(0); } if (argv.migrate) { // The user wants to migrate an old buildcom config file // Go to migrate function return (0, _helpers_1.printMessage)('🛠 This route does not exist yet.\r', 'notice'); } + /** HAPPY PATHS */ + if (argv.init) + return (0, init_1.default)({}); + if (argv._[0].toString() === 'add') { + const module = argv._[1].toString(); + return (0, add_module_1.default)({ path: module }); + } const commands = config ? (0, generate_commands_1.default)() : []; const commandString = process.argv[2].replace('--', ''); const command = commands.find((c) => c.name === commandString); - const getSubstitutions = (commandList) => { - const substitutions = []; - if (commandList.substitute) { - commandList.substitute.forEach((sub) => { - var _a; - // No substitution was provided but the config requires one - if (sub.required && !argv[sub.string]) { - (0, _helpers_1.throwError)(`"--${sub.string}" missing in arguments. This is required.\n`); - } - // User has not provided a substitution but the config has a default fallback value - if (sub.default && !argv[sub.string]) { - substitutions.push({ - replace: sub.string, - with: sub.default - }); - } - // User has provided the substitution argument - if (argv[sub.string]) { - const value = argv[sub.string] === true - ? '' - : argv[sub.string]; - // User has provided the substitution argument with no value - if (value === '') { - (0, _helpers_1.throwError)(`"--${sub.string}" requires a value`); - } - if (sub.valid && - value !== '' && - !((_a = sub.valid) === null || _a === void 0 ? void 0 : _a.includes(value))) { - (0, _helpers_1.throwError)(`\n"${value}" is not a valid ${sub.string}. Please use one of the following: \n - ${sub.valid.join(`\n - `)}\n`); - } - // The value provided is valid - substitutions.push({ - replace: sub.string, - with: argv[sub.string] - }); - } - }); - } - return substitutions; - }; - const substitute = getSubstitutions(command); + const substitute = command ? (0, _helpers_1.getSubstitutions)(command, argv) : []; if (command) { const name = argv._[1].toString(); return (0, build_from_scaffold_1.default)({ diff --git a/builda/dist/scripts/build-from-scaffold.js b/builda/dist/scripts/build-from-scaffold.js index dad98f63..14f1cfa6 100644 --- a/builda/dist/scripts/build-from-scaffold.js +++ b/builda/dist/scripts/build-from-scaffold.js @@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.buildFromScaffold = void 0; const fs_1 = __importDefault(require("fs")); -const prettier_1 = __importDefault(require("prettier")); // import helpers const _helpers_1 = require("../helpers/index.js"); const string_functions_1 = require("../helpers/string-functions"); @@ -37,7 +36,7 @@ const buildFromScaffold = ({ name, command, substitute }) => { } }; // Add a component registry file to the output directory - return fs_1.default.writeFileSync(`${outputDirectory}/registry.json`, prettier_1.default.format(JSON.stringify(componentRegistry), { parser: 'json' })); + return fs_1.default.writeFileSync(`${outputDirectory}/registry.json`, JSON.stringify(componentRegistry, null, 2)); } throw new Error('No config file found'); }; diff --git a/builda/dist/scripts/generate-scaffold-registry.js b/builda/dist/scripts/generate-scaffold-registry.js index 97128654..4d50e828 100644 --- a/builda/dist/scripts/generate-scaffold-registry.js +++ b/builda/dist/scripts/generate-scaffold-registry.js @@ -41,7 +41,7 @@ const generateScaffoldRegistry = (scaffoldPath) => { ] } `; - fs_1.default.writeFileSync(`${readPath}/${file}/registry.json`, JSON.stringify(page)); + fs_1.default.writeFileSync(`${readPath}/${file}/registry.json`, JSON.stringify(page, null, 2)); } }); }; diff --git a/builda/dist/scripts/init.js b/builda/dist/scripts/init.js index ea5a4a21..7dfbe7c9 100644 --- a/builda/dist/scripts/init.js +++ b/builda/dist/scripts/init.js @@ -39,6 +39,7 @@ const checkExistingConfig = (fileName, debug) => { }); } (0, _helpers_1.printMessage)('Starting initialisation...\r', 'success'); + (0, _helpers_1.printMessage)(`All answers can be changed later by editing the ${configFileName} file`, 'notice'); return resolve('yes'); }); }; diff --git a/builda/src/data/questions.ts b/builda/src/data/questions.ts index f8ffe319..3ad986d8 100644 --- a/builda/src/data/questions.ts +++ b/builda/src/data/questions.ts @@ -44,7 +44,8 @@ export default [ { type: 'checkbox', name: 'scaffoldSelection', - message: 'Select zero or more scaffold types you wish to use', + message: 'Select one or more scaffold types you wish to use', + default: ['component'], choices: [ 'component', 'atom', diff --git a/builda/src/helpers/get-module.ts b/builda/src/helpers/get-module.ts index ff36701a..b2e3e2a7 100644 --- a/builda/src/helpers/get-module.ts +++ b/builda/src/helpers/get-module.ts @@ -16,12 +16,11 @@ const moduleTypes = ['scaffold', 'prefab'] as ModuleType[]; export const getmodule = (name: string) => { if (config) { const moduleList = config.modules; - const moduleCategory = moduleTypes.find( - (category) => moduleList[category] && moduleList?.[category]?.[name] + const moduleType = moduleTypes.find( + (type) => moduleList[type] && moduleList?.[type]?.[name] ); - const path = `${globals.buildaDir}/modules/${moduleCategory}/${name}`; - console.log(path); + const path = `${globals.buildaDir}/modules/${moduleType}/${name}`; const registry = JSON.parse(fs.readFileSync(`${path}/registry.json`, 'utf8')); const files = registry.files.filter( (file: string) => file !== 'registry.json' diff --git a/builda/src/helpers/get-substitutions.ts b/builda/src/helpers/get-substitutions.ts new file mode 100644 index 00000000..57f345f5 --- /dev/null +++ b/builda/src/helpers/get-substitutions.ts @@ -0,0 +1,65 @@ +import throwError from "./throw-error"; + +import type CommandConfig from "@typedefs/command-config"; +import type TSubstitution from "@typedefs/substitution"; +import type { TSubstitute } from '@typedefs/command-config'; +import type { Argv } from "@typedefs/argv"; + + +export const getSubstitutions = (commandList: Partial, argv: Argv) => { + const substitutions = [] as TSubstitution[]; + if (commandList.substitute) { + commandList.substitute.forEach((sub: TSubstitute) => { + // No substitution was provided but the config requires one + if (sub.required && !argv[sub.string]) { + throwError( + `"--${sub.string}" missing in arguments. This is required.\n` + ); + } + + // User has not provided a substitution but the config has a default fallback value + if (sub.default && !argv[sub.string]) { + substitutions.push({ + replace: sub.string, + with: sub.default + }); + } + + // User has provided the substitution argument + if (argv[sub.string]) { + const value = + argv[sub.string] === true + ? '' + : (argv[sub.string] as string); + + // User has provided the substitution argument with no value + if (value === '') { + throwError(`"--${sub.string}" requires a value`); + } + + if ( + sub.valid && + value !== '' && + !sub.valid?.includes(value) + ) { + throwError( + `\n"${value}" is not a valid ${ + sub.string + }. Please use one of the following: \n - ${sub.valid.join( + `\n - ` + )}\n` + ); + } + + // The value provided is valid + substitutions.push({ + replace: sub.string, + with: argv[sub.string] as string + }); + } + }); + } + return substitutions; +}; + +export default getSubstitutions; diff --git a/builda/src/helpers/index.ts b/builda/src/helpers/index.ts index 61ee24f4..7ec95ae8 100644 --- a/builda/src/helpers/index.ts +++ b/builda/src/helpers/index.ts @@ -1,5 +1,6 @@ export { default as detectPathType } from './detect-path-type'; export { default as getConfigFile } from './get-config-file'; +export { default as getSubstitutions } from './get-substitutions'; export { default as getModule } from './get-module'; export { default as skip } from './skip'; export { default as printMessage } from './print-message'; diff --git a/builda/src/index.ts b/builda/src/index.ts index 824cb4f6..94ebeb46 100644 --- a/builda/src/index.ts +++ b/builda/src/index.ts @@ -9,38 +9,39 @@ import { askQuestion, getConfigFile, printLogo, - throwError + getSubstitutions } from '@helpers'; // import data import arguments from '@data/arguments.json'; +import globals from '@data/globals'; // import type definitions import type { QuestionType } from '@typedefs/question-type'; -import type { CommandConfig } from '@typedefs/command-config'; // import scripts import init from '@scripts/init'; import generateCommands from '@scripts/generate-commands'; import buildFromScaffold from '@scripts/build-from-scaffold'; import addModule from '@scripts/add-module'; -import { TSubstitute } from '@typedefs/command-config'; -import TSubstitution from '@typedefs/substitution'; const args = hideBin(process.argv); const config = getConfigFile(); +const { configFileName, websiteUrl } = globals; + const parser = yargs(args) .usage('Usage: $0 [options]') .options(arguments as { [key: string]: yargs.Options }) .help('h') .version() - .alias('h', 'help'); + .alias('h', 'help') + .epilogue(`For more information, visit ${websiteUrl}`); printLogo(); const CREATE_CONFIG_QUESTION = { - message: 'Would you like to create a .builda config?', + message: `Would you like to create a ${configFileName} config?`, name: 'createConfig', type: 'confirm' as QuestionType }; @@ -48,34 +49,38 @@ const CREATE_CONFIG_QUESTION = { (async () => { const argv = await parser.argv; - if (args.length === 0 && config) { - // No arguments were passed but a config file exists - printMessage('No arguments provided.\r', 'danger'); - parser.showHelp(); + /** UNHAPPY PATHS */ + + if (config) { + if (args.length === 0) { + // No arguments were passed but a config file exists + printMessage('No arguments provided.\r', 'danger'); + parser.showHelp(); + return process.exit(0); + } + + if (argv.init) { + printMessage(`A ${configFileName} has been found. Please delete it before continuing.\r`, 'danger'); + return process.exit(0); + } } if ((args.length === 0 || !argv.manual) && !config) { - printMessage('Builda config not detected.\r', 'danger'); + printMessage(`No ${configFileName} found. Please run the 'init' command.\r`, 'danger'); // No arguments were passed but a config file does not exist return askQuestion(CREATE_CONFIG_QUESTION).then(({ createConfig }) => { if (createConfig) { return init({}); } printMessage('Process terminated due to user selection', 'error'); - return process.exit(1); + return process.exit(0); }); } - if (argv.init) init({}); - if (argv.manual) { printMessage('Manual mode selected.\r', 'notice'); - return printMessage('🛠 This route does not exist yet.\r', 'notice'); - } - - if (argv._[0].toString() === 'add') { - const module = argv._[1].toString(); - return addModule({path: module}); + printMessage('🛠 This route does not exist yet.\r', 'notice'); + return process.exit(0); } if (argv.migrate) { @@ -84,69 +89,22 @@ const CREATE_CONFIG_QUESTION = { return printMessage('🛠 This route does not exist yet.\r', 'notice'); } + + /** HAPPY PATHS */ + if (argv.init) return init({}); + + if (argv._[0].toString() === 'add') { + const module = argv._[1].toString(); + return addModule({path: module}); + } + const commands = config ? generateCommands() : []; const commandString = process.argv[2].replace('--', ''); - const command = commands.find((c) => c.name === commandString) as CommandConfig; - - const getSubstitutions = (commandList: CommandConfig) => { - const substitutions = [] as TSubstitution[]; - if (commandList.substitute) { - commandList.substitute.forEach((sub: TSubstitute) => { - // No substitution was provided but the config requires one - if (sub.required && !argv[sub.string]) { - throwError( - `"--${sub.string}" missing in arguments. This is required.\n` - ); - } - - // User has not provided a substitution but the config has a default fallback value - if (sub.default && !argv[sub.string]) { - substitutions.push({ - replace: sub.string, - with: sub.default - }); - } - - // User has provided the substitution argument - if (argv[sub.string]) { - const value = - argv[sub.string] === true - ? '' - : (argv[sub.string] as string); - - // User has provided the substitution argument with no value - if (value === '') { - throwError(`"--${sub.string}" requires a value`); - } - - if ( - sub.valid && - value !== '' && - !sub.valid?.includes(value) - ) { - throwError( - `\n"${value}" is not a valid ${ - sub.string - }. Please use one of the following: \n - ${sub.valid.join( - `\n - ` - )}\n` - ); - } - - // The value provided is valid - substitutions.push({ - replace: sub.string, - with: argv[sub.string] as string - }); - } - }); - } - return substitutions; - }; + const command = commands.find((c) => c.name === commandString); - const substitute = getSubstitutions(command); + const substitute = command ? getSubstitutions(command, argv) : []; if (command) { const name = argv._[1].toString(); diff --git a/builda/src/scripts/build-from-scaffold.ts b/builda/src/scripts/build-from-scaffold.ts index 18cb6a1b..94a3060e 100644 --- a/builda/src/scripts/build-from-scaffold.ts +++ b/builda/src/scripts/build-from-scaffold.ts @@ -1,5 +1,4 @@ import fs from 'fs'; -import prettier from 'prettier'; // import helpers import { getConfigFile, printMessage, getModule, writeFile } from '@helpers'; @@ -62,7 +61,7 @@ export const buildFromScaffold = ({ // Add a component registry file to the output directory return fs.writeFileSync( `${outputDirectory}/registry.json`, - prettier.format(JSON.stringify(componentRegistry), { parser: 'json' }) + JSON.stringify(componentRegistry, null, 2) ); } throw new Error('No config file found'); diff --git a/builda/src/scripts/generate-scaffold-registry.ts b/builda/src/scripts/generate-scaffold-registry.ts index f0a4273c..32a840af 100644 --- a/builda/src/scripts/generate-scaffold-registry.ts +++ b/builda/src/scripts/generate-scaffold-registry.ts @@ -42,7 +42,7 @@ export const generateScaffoldRegistry = (scaffoldPath?: string) => { } `; - fs.writeFileSync(`${readPath}/${file}/registry.json`, JSON.stringify(page)); + fs.writeFileSync(`${readPath}/${file}/registry.json`, JSON.stringify(page, null, 2)); } }); }; diff --git a/builda/src/scripts/init.ts b/builda/src/scripts/init.ts index 08dd4db6..f672b57f 100644 --- a/builda/src/scripts/init.ts +++ b/builda/src/scripts/init.ts @@ -55,6 +55,7 @@ const checkExistingConfig = (fileName: string, debug: boolean) => { ); } printMessage('Starting initialisation...\r', 'success'); + printMessage(`All answers can be changed later by editing the ${configFileName} file`, 'notice'); return resolve('yes'); }); }; diff --git a/builda/src/scripts/tests/generate-commands.test.ts b/builda/src/scripts/tests/generate-commands.test.ts index 4e6ae474..f6d95f74 100644 --- a/builda/src/scripts/tests/generate-commands.test.ts +++ b/builda/src/scripts/tests/generate-commands.test.ts @@ -3,6 +3,7 @@ import init from '@scripts/init'; import presetAnswers from '@mocks/preset-answers'; describe('generateCommands() function happy path', () => { + beforeAll(async () => { jest.spyOn(console, 'log').mockImplementation(() => null); await init({presetAnswers, force: true}); diff --git a/builda/src/types/argv.d.ts b/builda/src/types/argv.d.ts new file mode 100644 index 00000000..7c42ce1c --- /dev/null +++ b/builda/src/types/argv.d.ts @@ -0,0 +1,15 @@ +import { argv } from "process"; + +export type Argv = { + [x: string]: unknown; + help: unknown; + _: (string | number)[]; + $0: string; +} | { + [x: string]: unknown; + help: unknown; + _: (string | number)[]; + $0: string; +} + +export default argv;