-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adds .builda.json to gitignore (replacing yml) - Splits index.ts into a more logical order - Moves get-substitutions into it's own helper - Adds some extra user feedback - Adds a catcher to stop functions running if config exists and 'init' is called - Adds 'Argv' type definition
- Loading branch information
1 parent
4af9332
commit d1c8d88
Showing
21 changed files
with
239 additions
and
205 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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
npm-debug.log | ||
/components | ||
log.txt | ||
.builda.yml | ||
.builda.json | ||
.buildcomrc | ||
.nyc_output/ | ||
coverage/ | ||
|
This file was deleted.
Oops, something went wrong.
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,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" | ||
] | ||
} | ||
} |
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 |
---|---|---|
@@ -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; |
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
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
Oops, something went wrong.