light-generator
Advanced tools
Comparing version 1.3.2 to 1.3.3
@@ -26,3 +26,3 @@ "use strict"; | ||
try { | ||
const pkg = require(templatePkg); | ||
const pkg = fs_1.readFileSync(templatePkg); | ||
const config = pkg['boilerplateConfig']; | ||
@@ -34,3 +34,4 @@ if (config) { | ||
} | ||
config.replaceParameter = config.replaceParameter || 'index.js'; | ||
config.replaceParameter = | ||
config.replaceParameter || 'index.js'; | ||
config.root = path_1.join(templateRoot, config.root || 'boilerplate'); | ||
@@ -52,3 +53,3 @@ config.rule = config.rule || []; | ||
async getParameterList() { | ||
const templateConfig = await this.getTemplateConfig(); | ||
const templateConfig = (await this.getTemplateConfig()); | ||
const templateRoot = this.getTemplatePath(); | ||
@@ -86,3 +87,3 @@ if (templateConfig) { | ||
} | ||
let templateConfig = await this.getTemplateConfig(); | ||
let templateConfig = (await this.getTemplateConfig()); | ||
let templateRoot = this.getTemplatePath(); | ||
@@ -112,3 +113,4 @@ const packageRoot = templateRoot; | ||
if (templateConfig.afterAll) { | ||
const afterScript = path_1.isAbsolute(templateConfig.afterAll) ? require(templateConfig.afterAll) | ||
const afterScript = path_1.isAbsolute(templateConfig.afterAll) | ||
? require(templateConfig.afterAll) | ||
: require(path_1.join(packageRoot, templateConfig.afterAll)); | ||
@@ -128,2 +130,2 @@ if (afterScript && typeof afterScript === 'function') { | ||
exports.CommonGenerator = CommonGenerator; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ29tbW9uR2VuZXJhdG9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2dlbmVyYXRvci9Db21tb25HZW5lcmF0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFDQSwrQkFBd0M7QUFDeEMsbUNBQTJEO0FBQzNELDBEQUFrQztBQUNsQywwREFBaUM7QUFFakMsTUFBc0IsZUFBZTtJQVFuQyxZQUFZLE9BQStCO1FBQ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BQyxjQUFjLENBQUMsUUFBUSxDQUFDO2dCQUNyRCxDQUFDLENBQUMsT0FBTyxDQUFDLGNBQWMsQ0FBQyxRQUFRLENBQUM7Z0JBQ2xDLENBQUMsQ0FBQyxPQUFPLENBQUMsV0FBSSxDQUFDLFdBQVcsRUFBRSxjQUFjLENBQUMsUUFBUSxDQUFDLENBQUMsQ0FBQztZQUN4RCxJQUFJLFdBQVcsSUFBSSxPQUFPLFdBQVcsS0FBSyxVQUFVLEVBQUU7Z0JBQ3BELE1BQU0sV0FBVyxDQUFDO29CQUNoQixVQUFVLEVBQUUsV0FBVztvQkFDdkIsWUFBWTtvQkFDWixVQUFVLEVBQUUsV0FBVztvQkFDdkIsZ0JBQWdCLEVBQUUsTUFBTSxDQUFDLE1BQU0sQ0FBQyxnQkFBZ0IsRUFBRSxnQkFBZ0IsQ0FBQztvQkFDbkUsY0FBYztpQkFDZixDQUFDLENBQUM7YUFDSjtTQUNGO0lBQ0gsQ0FBQztDQUdGO0FBcklELDBDQXFJQyJ9 |
@@ -25,3 +25,6 @@ "use strict"; | ||
this.npmClient = options.npmClient; | ||
this.tmpPath = path_1.join(os_1.tmpdir(), 'gen_' + Date.now().toString().slice(0, 5)); | ||
this.tmpPath = path_1.join(os_1.tmpdir(), 'gen_' + | ||
Date.now() | ||
.toString() | ||
.slice(0, 5)); | ||
fse.ensureDirSync(this.tmpPath); | ||
@@ -31,3 +34,3 @@ } | ||
const data = child_process_1.execSync(`${this.npmClient} view ${this.templateUri} dist-tags --json`, { | ||
cwd: process.env.HOME | ||
cwd: process.env.HOME, | ||
}).toString(); | ||
@@ -38,10 +41,14 @@ const remoteVersion = JSON.parse(data)['latest']; | ||
if (!fs_1.dirExistsSync(currentPkgRoot)) { | ||
// clean template directory first | ||
if (fs_1.dirExistsSync(this.pkgRootName)) { | ||
await fse.remove(this.pkgRootName); | ||
} | ||
const cmd = `${this.npmClient} pack ${this.templateUri}@${remoteVersion} | mkdir ${this.pkgRootName}`; | ||
child_process_1.execSync(cmd, { | ||
cwd: this.tmpPath, | ||
stdio: ['pipe', 'ignore', 'pipe'] | ||
stdio: ['pipe', 'ignore', 'pipe'], | ||
}); | ||
await tar.x({ | ||
file: path_1.join(this.tmpPath, `${this.pkgRootName}.tgz`), | ||
C: path_1.join(this.tmpPath, this.pkgRootName) | ||
C: path_1.join(this.tmpPath, this.pkgRootName), | ||
}); | ||
@@ -62,2 +69,2 @@ if (!fs_1.dirExistsSync(currentPkgRoot)) { | ||
exports.NpmPatternGenerator = NpmPatternGenerator; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTnBtUGF0dGVybkdlbmVyYXRvci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9nZW5lcmF0b3IvTnBtUGF0dGVybkdlbmVyYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFBQSx1REFBb0Q7QUFFcEQsaURBQXlDO0FBQ3pDLCtCQUE0QjtBQUM1QiwyQkFBNEI7QUFDNUIsOENBQWdDO0FBQ2hDLG1DQUEyQztBQUMzQyx5Q0FBMkI7QUFFM0IsU0FBZ0IsaUJBQWlCLENBQUMsT0FBTztJQUN2QyxPQUFPLE9BQU8sQ0FBQyxPQUFPLENBQUMsV0FBVyxFQUFFLEtBQUssQ0FBQyxDQUFDO0FBQzdDLENBQUM7QUFGRCw4Q0FFQztBQUVELE1BQWEsbUJBQW9CLFNBQVEsaUNBQWU7SUFNdEQsWUFBWSxPQUE0QjtRQUN0QyxLQUFLLENBQUMsT0FBTyxDQUFDLENBQUM7UUFDZixJQUFJLENBQUMsU0FBUyxHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQUM7UUFDbkMsSUFBSSxDQUFDLE9BQU8sR0FBRyxXQUFJLENBQUMsV0FBTSxFQUFFLEVBQUUsTUFBTSxHQUFHLElBQUksQ0FBQyxHQUFHLEVBQUUsQ0FBQ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yxLQUFLLENBQUMsaUJBQWlCLEVBQUUsQ0FBQztJQUNuQyxDQUFDO0lBRUQsZUFBZTtRQUNiLE9BQU8sV0FBSSxDQUFDLElBQUksQ0FBQyxPQUFPLEVBQUUsSUFBSSxDQUFDLFdBQVcsRUFBRSxTQUFTLENBQUMsQ0FBQztJQUN6RCxDQUFDO0NBQ0Y7QUE1REQsa0RBNERDIn0= |
1.3.3 / 2019-10-29 | ||
================== | ||
* chore: fix #12 | ||
* fix: fix object required cache | ||
1.3.2 / 2019-09-11 | ||
@@ -3,0 +9,0 @@ ================== |
{ | ||
"name": "light-generator", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "light generator for generate a boilerplate", | ||
@@ -5,0 +5,0 @@ "main": "dist/index", |
@@ -1,4 +0,8 @@ | ||
import { CommonGeneratorOptions, CopyWalker, TemplatePackageConfig } from '../interface'; | ||
import { | ||
CommonGeneratorOptions, | ||
CopyWalker, | ||
TemplatePackageConfig, | ||
} from '../interface'; | ||
import { isAbsolute, join } from 'path'; | ||
import { dirExistsSync, fileExistsSync } from '../util/fs'; | ||
import { dirExistsSync, fileExistsSync, readFileSync } from '../util/fs'; | ||
import untildify from 'untildify'; | ||
@@ -8,3 +12,2 @@ import emptyDir from 'empty-dir'; | ||
export abstract class CommonGenerator { | ||
copyWalker: CopyWalker; | ||
@@ -33,10 +36,11 @@ templateUri: string; | ||
try { | ||
const pkg = require(templatePkg); | ||
const config = pkg[ 'boilerplateConfig' ] as TemplatePackageConfig; | ||
const pkg = readFileSync(templatePkg); | ||
const config = pkg['boilerplateConfig'] as TemplatePackageConfig; | ||
if (config) { | ||
config.replaceFile = config.replaceFile || [ 'README.md' ]; | ||
config.replaceFile = config.replaceFile || ['README.md']; | ||
if (typeof config.replaceFile === 'string') { | ||
config.replaceFile = [ config.replaceFile ]; | ||
config.replaceFile = [config.replaceFile]; | ||
} | ||
config.replaceParameter = config.replaceParameter as string || 'index.js'; | ||
config.replaceParameter = | ||
(config.replaceParameter as string) || 'index.js'; | ||
config.root = join(templateRoot, config.root || 'boilerplate'); | ||
@@ -58,6 +62,9 @@ config.rule = config.rule || []; | ||
async getParameterList() { | ||
const templateConfig = await this.getTemplateConfig() as TemplatePackageConfig; | ||
const templateConfig = (await this.getTemplateConfig()) as TemplatePackageConfig; | ||
const templateRoot = this.getTemplatePath(); | ||
if (templateConfig) { | ||
const parameterFile = join(templateRoot, templateConfig.replaceParameter as string); | ||
const parameterFile = join( | ||
templateRoot, | ||
templateConfig.replaceParameter as string | ||
); | ||
if (fileExistsSync(parameterFile)) { | ||
@@ -77,4 +84,4 @@ return require(parameterFile); | ||
for (const key in parameterList) { | ||
if (parameterList[ key ][ 'default' ]) { | ||
defaultValue[ key ] = parameterList[ key ][ 'default' ]; | ||
if (parameterList[key]['default']) { | ||
defaultValue[key] = parameterList[key]['default']; | ||
} | ||
@@ -96,3 +103,5 @@ } | ||
let templateConfig = await this.getTemplateConfig() as Partial<TemplatePackageConfig>; | ||
let templateConfig = (await this.getTemplateConfig()) as Partial< | ||
TemplatePackageConfig | ||
>; | ||
let templateRoot = this.getTemplatePath(); | ||
@@ -109,3 +118,3 @@ const packageRoot = templateRoot; | ||
root: templateRoot, | ||
replaceFile: [ 'README.md' ], | ||
replaceFile: ['README.md'], | ||
rule: [], | ||
@@ -125,3 +134,4 @@ }; | ||
if (templateConfig.afterAll) { | ||
const afterScript = isAbsolute(templateConfig.afterAll) ? require(templateConfig.afterAll) | ||
const afterScript = isAbsolute(templateConfig.afterAll) | ||
? require(templateConfig.afterAll) | ||
: require(join(packageRoot, templateConfig.afterAll)); | ||
@@ -128,0 +138,0 @@ if (afterScript && typeof afterScript === 'function') { |
@@ -15,3 +15,2 @@ import { CommonGenerator } from './CommonGenerator'; | ||
export class NpmPatternGenerator extends CommonGenerator { | ||
npmClient: string; | ||
@@ -24,3 +23,9 @@ tmpPath: string; | ||
this.npmClient = options.npmClient; | ||
this.tmpPath = join(tmpdir(), 'gen_' + Date.now().toString().slice(0, 5)); | ||
this.tmpPath = join( | ||
tmpdir(), | ||
'gen_' + | ||
Date.now() | ||
.toString() | ||
.slice(0, 5) | ||
); | ||
fse.ensureDirSync(this.tmpPath); | ||
@@ -30,13 +35,22 @@ } | ||
private async getPackage() { | ||
const data = execSync(`${this.npmClient} view ${this.templateUri} dist-tags --json`, { | ||
cwd: process.env.HOME | ||
}).toString(); | ||
const remoteVersion = JSON.parse(data)[ 'latest' ]; | ||
this.pkgRootName = `${renamePackageName(this.templateUri)}-${remoteVersion}`; | ||
const data = execSync( | ||
`${this.npmClient} view ${this.templateUri} dist-tags --json`, | ||
{ | ||
cwd: process.env.HOME, | ||
} | ||
).toString(); | ||
const remoteVersion = JSON.parse(data)['latest']; | ||
this.pkgRootName = `${renamePackageName( | ||
this.templateUri | ||
)}-${remoteVersion}`; | ||
const currentPkgRoot = this.getTemplatePath(); | ||
if (!dirExistsSync(currentPkgRoot)) { | ||
// clean template directory first | ||
if (dirExistsSync(this.pkgRootName)) { | ||
await fse.remove(this.pkgRootName); | ||
} | ||
const cmd = `${this.npmClient} pack ${this.templateUri}@${remoteVersion} | mkdir ${this.pkgRootName}`; | ||
execSync(cmd, { | ||
cwd: this.tmpPath, | ||
stdio: [ 'pipe', 'ignore', 'pipe' ] | ||
stdio: ['pipe', 'ignore', 'pipe'], | ||
}); | ||
@@ -46,3 +60,3 @@ | ||
file: join(this.tmpPath, `${this.pkgRootName}.tgz`), | ||
C: join(this.tmpPath, this.pkgRootName) | ||
C: join(this.tmpPath, this.pkgRootName), | ||
}); | ||
@@ -64,3 +78,2 @@ | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
97511
1675
13