copy-config
Advanced tools
Comparing version 0.1.1 to 0.2.0
export type { MergeStrategy } from './merge'; | ||
export * as mergeStrategies from './merge'; | ||
export * from './config'; | ||
export * from './configs'; | ||
export * from './run'; |
@@ -31,3 +31,3 @@ "use strict"; | ||
exports.mergeStrategies = __importStar(require("./merge")); | ||
__exportStar(require("./config"), exports); | ||
__exportStar(require("./configs"), exports); | ||
__exportStar(require("./run"), exports); |
@@ -37,3 +37,3 @@ "use strict"; | ||
const path = __importStar(require("path")); | ||
const config_1 = require("./config"); | ||
const configs_1 = require("./configs"); | ||
const run = async ({ fs = realFs, cwd = process.cwd(), argv = process.argv.slice(2), logger = console, } = {}) => { | ||
@@ -53,4 +53,17 @@ const argSpec = { | ||
if (args['--help']) { | ||
const options = Object.entries(argSpec).map(([k, v]) => `${k}: ${v.name}`); | ||
logger.info(`Available options: ${options.join(', ')}`); | ||
// crappy markdown parser! | ||
const readme = realFs.readFileSync(path.join(__dirname, '../README.md')).toString(); | ||
const optionDocs = readme.split('### ').flatMap(section => { | ||
if (!section.startsWith('`--')) | ||
return []; | ||
const option = section.split('`')[1]; | ||
const doc = section | ||
.slice(option.length + 2) | ||
.split('\n#')[0] | ||
.trim(); | ||
return [{ option, doc }]; | ||
}); | ||
const options = Object.entries(argSpec).map(([k, v]) => { var _a; return `${k} ${v.name.replace('Boolean', '')}\n${((_a = optionDocs.find(o => o.option === k)) === null || _a === void 0 ? void 0 : _a.doc) || ''}`; }); | ||
logger.info(`Available options:\n\n${options.join('\n\n')}`); | ||
return; | ||
} | ||
@@ -69,3 +82,3 @@ const outputPath = path.resolve(cwd, args['--output'] || '.'); | ||
const tempRepoDir = path.join(tempDir, fs.readdirSync(tempDir)[0]); | ||
return tempRepoDir; | ||
return path.join(tempRepoDir, args['--path'] || '.'); | ||
}; | ||
@@ -77,3 +90,3 @@ const getLocalDir = () => { | ||
}; | ||
const copyFrom = args['--path'] ? getLocalDir() : getTempRepoDir(); | ||
const copyFrom = args['--repo'] ? getTempRepoDir() : getLocalDir(); | ||
if (args['--ref']) { | ||
@@ -84,6 +97,6 @@ cp.execSync(`git fetch`, { cwd: copyFrom }); | ||
const config = args['--config'] | ||
? require(args['--config']) // eslint-disable-line mmkal/@typescript-eslint/no-require-imports | ||
? require(args['--config'].replace('%source%', copyFrom)) // eslint-disable-line mmkal/@typescript-eslint/no-require-imports | ||
: args['--aggressive'] | ||
? config_1.aggressiveConfig | ||
: config_1.defaultConfig; | ||
? configs_1.aggressiveConfig | ||
: configs_1.defaultConfig; | ||
const handled = new Set(); | ||
@@ -90,0 +103,0 @@ const globSync = (pattern, options) => (0, glob_1.globSync)(pattern, Object.assign({ dot: true }, options)); |
{ | ||
"name": "copy-config", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Copies another repo's configuration", | ||
@@ -29,7 +29,7 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@types/eslint": "8.37.0", | ||
"@types/jest": "29.5.0", | ||
"@types/lodash": "4.14.194", | ||
"eslint": "8.38.0", | ||
"eslint-plugin-mmkal": "0.0.1-2", | ||
"@types/eslint": "8.40.0", | ||
"@types/jest": "29.5.1", | ||
"@types/lodash": "4.14.195", | ||
"eslint": "8.41.0", | ||
"eslint-plugin-mmkal": "0.1.2", | ||
"fs-syncer": "0.4.0", | ||
@@ -39,3 +39,3 @@ "jest": "29.5.0", | ||
"typescript": "5.0.4", | ||
"np": "7.7.0" | ||
"np": "8.0.1" | ||
}, | ||
@@ -42,0 +42,0 @@ "files": [ |
@@ -82,2 +82,12 @@ # copy-config | ||
You can also use the special placeholder variable `%source%` to require a file relative to the project you're copying from. For example: | ||
```bash | ||
npx copy-config --repo someuser/somerepo --config %source%/configs/someconfig.js | ||
``` | ||
### `--help` | ||
Show help text. | ||
## Merge strategies | ||
@@ -84,0 +94,0 @@ |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
38360
15
450
122