Skip to content

Commit e54f61c

Browse files
committed
build: update deps
1 parent ebec7ab commit e54f61c

File tree

4 files changed

+119
-114
lines changed

4 files changed

+119
-114
lines changed

cg.js

+15-16
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,22 @@ function finishLocal(err,result) {
115115
function finishRemote(err,result) {
116116
configName = configName.split(':').pop();
117117
if (argv.verbose) console.log('Making/cleaning output directories');
118-
mkdirp(path.join(config.outputDir,configName),function(){
119-
rimraf(path.join(config.outputDir,configName)+'/*',function(){
120-
if (argv.zip) {
121-
fs.writeFileSync(path.join(config.outputDir,configName,configName+'.zip'),result);
122-
}
123-
else {
124-
const zip = new admzip(result);
125-
if (argv.verbose) {
126-
console.log('Unzipping...');
127-
const zipEntries = zip.getEntries(); // an array of ZipEntry records
128-
zipEntries.forEach(function(zipEntry) {
129-
console.log(zipEntry.entryName);
130-
});
131-
}
132-
zip.extractAllTo(config.outputDir,true);
118+
mkdirp.sync(path.join(config.outputDir,configName));
119+
rimraf(path.join(config.outputDir,configName)+'/*',function(){
120+
if (argv.zip) {
121+
fs.writeFileSync(path.join(config.outputDir,configName,configName+'.zip'),result);
122+
}
123+
else {
124+
const zip = new admzip(result);
125+
if (argv.verbose) {
126+
console.log('Unzipping...');
127+
const zipEntries = zip.getEntries(); // an array of ZipEntry records
128+
zipEntries.forEach(function(zipEntry) {
129+
console.log(zipEntry.entryName);
130+
});
133131
}
134-
});
132+
zip.extractAllTo(config.outputDir,true);
133+
}
135134
});
136135
}
137136

local.js

+90-91
Original file line numberDiff line numberDiff line change
@@ -66,123 +66,122 @@ function main(o, config, configName, callback) {
6666
const subDir = (config.defaults.flat ? '' : configName);
6767

6868
if (verbose) console.log('Making/cleaning output directories');
69-
ff.mkdirp(path.join(outputDir,subDir),function(){
70-
ff.rimraf(path.join(outputDir,subDir)+'/*',function(){
71-
if (config.directories) {
72-
for (let directory of config.directories) {
73-
ff.mkdirp.sync(path.join(outputDir,subDir,directory));
74-
}
69+
ff.mkdirp.sync(path.join(outputDir,subDir));
70+
ff.rimraf(path.join(outputDir,subDir)+'/*',function(){
71+
if (config.directories) {
72+
for (let directory of config.directories) {
73+
ff.mkdirp.sync(path.join(outputDir,subDir,directory));
7574
}
76-
for (let action of actions) {
77-
if (verbose) console.log('Rendering '+action.output);
78-
let content;
79-
if (config.generator && config.generator.render) {
80-
content = config.generator.render(action.template, model, config.partials);
81-
} else {
82-
let template = Hogan.compile(action.template);
83-
content = template.render(model,config.partials);
84-
}
85-
ff.createFile(path.join(outputDir,subDir,action.output),content,'utf8');
75+
}
76+
for (let action of actions) {
77+
if (verbose) console.log('Rendering '+action.output);
78+
let content;
79+
if (config.generator && config.generator.render) {
80+
content = config.generator.render(action.template, model, config.partials);
81+
} else {
82+
let template = Hogan.compile(action.template);
83+
content = template.render(model,config.partials);
8684
}
87-
if (config.touch) { // may not now be necessary
88-
let touchTmp = Hogan.compile(config.touch);
89-
let touchList = touchTmp.render(model,config.partials);
90-
let files = touchList.split('\r').join('').split('\n');
91-
for (let file of files) {
92-
file = file.trim();
93-
if (file) {
94-
if (!fs.existsSync(path.join(outputDir,subDir,file))) {
95-
ff.createFile(path.join(outputDir,subDir,file),'','utf8');
96-
}
85+
ff.createFile(path.join(outputDir,subDir,action.output),content,'utf8');
86+
}
87+
if (config.touch) { // may not now be necessary
88+
let touchTmp = Hogan.compile(config.touch);
89+
let touchList = touchTmp.render(model,config.partials);
90+
let files = touchList.split('\r').join('').split('\n');
91+
for (let file of files) {
92+
file = file.trim();
93+
if (file) {
94+
if (!fs.existsSync(path.join(outputDir,subDir,file))) {
95+
ff.createFile(path.join(outputDir,subDir,file),'','utf8');
9796
}
9897
}
9998
}
99+
}
100100

101-
// generate license by default
102-
if (typeof config.license === 'undefined') {
103-
config.license = true;
104-
}
101+
// generate license by default
102+
if (typeof config.license === 'undefined') {
103+
config.license = true;
104+
}
105105

106-
if (config.license) {
107-
const licenseType = config.apache ? 'LICENSE' : 'UNLICENSE';
108-
ff.createFile(path.join(outputDir, subDir, 'LICENSE'), ff.readFileSync(tpl({}, '_common', licenseType), 'utf8'), 'utf8');
109-
}
106+
if (config.license) {
107+
const licenseType = config.apache ? 'LICENSE' : 'UNLICENSE';
108+
ff.createFile(path.join(outputDir, subDir, 'LICENSE'), ff.readFileSync(tpl({}, '_common', licenseType), 'utf8'), 'utf8');
109+
}
110110

111-
let outer = model;
112-
113-
if (config.perApi) {
114-
let toplevel = clone(model);
115-
delete toplevel.apiInfo;
116-
for (let pa of config.perApi) {
117-
let fnTemplate = Hogan.compile(pa.output);
118-
let template = Hogan.compile(ff.readFileSync(tpl(config, configName, pa.input), 'utf8'));
119-
for (let api of model.apiInfo.apis) {
120-
let cApi = Object.assign({},config.defaults,pa.defaults||{},toplevel,api);
121-
let filename = fnTemplate.render(cApi,config.partials);
122-
if (verbose) console.log('Rendering '+filename+' (dynamic:'+pa.input+')');
123-
ff.createFile(path.join(outputDir,subDir,filename),template.render(cApi,config.partials),'utf8');
124-
}
111+
let outer = model;
112+
113+
if (config.perApi) {
114+
let toplevel = clone(model);
115+
delete toplevel.apiInfo;
116+
for (let pa of config.perApi) {
117+
let fnTemplate = Hogan.compile(pa.output);
118+
let template = Hogan.compile(ff.readFileSync(tpl(config, configName, pa.input), 'utf8'));
119+
for (let api of model.apiInfo.apis) {
120+
let cApi = Object.assign({},config.defaults,pa.defaults||{},toplevel,api);
121+
let filename = fnTemplate.render(cApi,config.partials);
122+
if (verbose) console.log('Rendering '+filename+' (dynamic:'+pa.input+')');
123+
ff.createFile(path.join(outputDir,subDir,filename),template.render(cApi,config.partials),'utf8');
125124
}
126125
}
126+
}
127127

128-
if (config.perPath) {
129-
let toplevel = clone(model);
130-
delete toplevel.apiInfo;
131-
for (let pa of config.perPath) {
132-
let fnTemplate = Hogan.compile(pa.output);
133-
let template = Hogan.compile(ff.readFileSync(tpl(config, configName, pa.input), 'utf8'));
134-
for (let pat of model.apiInfo.paths) {
135-
let cPath = Object.assign({},config.defaults,pa.defaults||{},toplevel,pat);
136-
let filename = fnTemplate.render(cPath,config.partials);
137-
let dirname = path.dirname(filename);
138-
if (verbose) console.log('Rendering '+filename+' (dynamic:'+pa.input+')');
139-
ff.mkdirp.sync(path.join(outputDir,subDir,dirname));
140-
ff.createFile(path.join(outputDir,subDir,filename),template.render(cPath,config.partials),'utf8');
141-
}
128+
if (config.perPath) {
129+
let toplevel = clone(model);
130+
delete toplevel.apiInfo;
131+
for (let pa of config.perPath) {
132+
let fnTemplate = Hogan.compile(pa.output);
133+
let template = Hogan.compile(ff.readFileSync(tpl(config, configName, pa.input), 'utf8'));
134+
for (let pat of model.apiInfo.paths) {
135+
let cPath = Object.assign({},config.defaults,pa.defaults||{},toplevel,pat);
136+
let filename = fnTemplate.render(cPath,config.partials);
137+
let dirname = path.dirname(filename);
138+
if (verbose) console.log('Rendering '+filename+' (dynamic:'+pa.input+')');
139+
ff.mkdirp.sync(path.join(outputDir,subDir,dirname));
140+
ff.createFile(path.join(outputDir,subDir,filename),template.render(cPath,config.partials),'utf8');
142141
}
143142
}
143+
}
144144

145-
if (config.perModel) {
146-
let cModels = clone(model.models);
147-
for (let pm of config.perModel) {
148-
let fnTemplate = Hogan.compile(pm.output);
149-
let template = Hogan.compile(ff.readFileSync(tpl(config, configName, pm.input), 'utf8'));
150-
for (let model of cModels) {
151-
outer.models = [];
152-
let effModel = Object.assign({},model,pm.defaults||{});
153-
outer.models.push(effModel);
154-
let filename = fnTemplate.render(outer,config.partials);
155-
if (verbose) console.log('Rendering '+filename+' (dynamic:'+pm.input+')');
156-
ff.createFile(path.join(outputDir,subDir,filename),template.render(outer,config.partials),'utf8');
157-
}
145+
if (config.perModel) {
146+
let cModels = clone(model.models);
147+
for (let pm of config.perModel) {
148+
let fnTemplate = Hogan.compile(pm.output);
149+
let template = Hogan.compile(ff.readFileSync(tpl(config, configName, pm.input), 'utf8'));
150+
for (let model of cModels) {
151+
outer.models = [];
152+
let effModel = Object.assign({},model,pm.defaults||{});
153+
outer.models.push(effModel);
154+
let filename = fnTemplate.render(outer,config.partials);
155+
if (verbose) console.log('Rendering '+filename+' (dynamic:'+pm.input+')');
156+
ff.createFile(path.join(outputDir,subDir,filename),template.render(outer,config.partials),'utf8');
158157
}
159158
}
159+
}
160160

161-
if (config.perOperation) { // now may not be necessary
162-
for (let po of config.perOperation) {
163-
for (let api of outer.apiInfo.apis) {
164-
let cOperations = clone(api.operations);
165-
let fnTemplate = Hogan.compile(po.output);
166-
let template = Hogan.compile(ff.readFileSync(tpl(config, configName, po.input), 'utf8'));
167-
for (let operation of cOperations.operation) {
168-
model.operations = [];
169-
model.operations.push(operation);
170-
let filename = fnTemplate.render(outer,config.partials);
171-
if (verbose) console.log('Rendering '+filename+' (dynamic:'+po.input+')');
172-
ff.createFile(path.join(outputDir,subDir,filename),template.render(outer,config.partials),'utf8');
173-
}
161+
if (config.perOperation) { // now may not be necessary
162+
for (let po of config.perOperation) {
163+
for (let api of outer.apiInfo.apis) {
164+
let cOperations = clone(api.operations);
165+
let fnTemplate = Hogan.compile(po.output);
166+
let template = Hogan.compile(ff.readFileSync(tpl(config, configName, po.input), 'utf8'));
167+
for (let operation of cOperations.operation) {
168+
model.operations = [];
169+
model.operations.push(operation);
170+
let filename = fnTemplate.render(outer,config.partials);
171+
if (verbose) console.log('Rendering '+filename+' (dynamic:'+po.input+')');
172+
ff.createFile(path.join(outputDir,subDir,filename),template.render(outer,config.partials),'utf8');
174173
}
175174
}
176175
}
176+
}
177177

178-
if (callback) callback(null,true);
179-
});
178+
if (callback) callback(null,true);
180179
});
181180
});
182181
}
183182

184183
module.exports = {
185184
fileFunctions: ff,
186-
main : main
185+
main
187186
};
188187

package-lock.json

+13-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"connect": "^3.6.5",
3434
"fast-safe-stringify": "^2.0.7",
3535
"hogan.js": "^3.0.2",
36-
"mkdirp": "^0.5.4",
36+
"mkdirp": "^1.0.4",
3737
"node-fetch": "^2.0.0",
3838
"oas-schema-walker": "^1.1.3",
3939
"oas-validator": "^5.0.4",

0 commit comments

Comments
 (0)