zarro 1.168.2 → 1.168.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,8 +20,16 @@
20
20
  const node = packageVersionPropGroup.PackageVersion;
21
21
  const newVersion = incrementVersion(node[0], env.resolveFlag("BETA")
22
22
  ? env.resolveWithFallback(env.VERSION_INCREMENT_STRATEGY, "prerelease")
23
- : env.resolve(env.VERSION_INCREMENT_STRATEGY), env.resolveFlag("VERSION_INCREMENT_ZERO"), env.resolveNumber("PACK_INCREMENT_VERSION_BY"));
23
+ : env.resolve(env.VERSION_INCREMENT_STRATEGY), env.resolveFlag(env.VERSION_INCREMENT_ZERO), env.resolveNumber(env.PACK_INCREMENT_VERSION_BY));
24
24
  node[0] = newVersion;
25
+ const incrementProjectVersion = env.resolveFlag(env.PACK_SYNC_PROJECT_VERSION);
26
+ if (incrementProjectVersion) {
27
+ const projectVersionPropGroup = xml.Project.PropertyGroup.filter((g) => !!g.Version);
28
+ if (!projectVersionPropGroup) {
29
+ throw new ZarroError(`${env.PACK_SYNC_PROJECT_VERSION} was set, but no PropertyGroup with a Version child was found.`);
30
+ }
31
+ projectVersionPropGroup.Version[0] = newVersion;
32
+ }
25
33
  let packageIdPropGroup = xml.Project.PropertyGroup.filter((g) => !!g.PackageId)[0];
26
34
  let packageName = "(unknown)";
27
35
  if (!packageIdPropGroup) {
@@ -10,11 +10,10 @@
10
10
  await dotnetCli.nugetPush(opts);
11
11
  }
12
12
  async function nugetPush(packageFile, sourceName, options) {
13
- var _a;
14
13
  const nugetPushSource = sourceName ||
15
14
  env.resolve(env.NUGET_PUSH_SOURCE, env.NUGET_SOURCE) ||
16
15
  "nuget.org";
17
- const apiKey = (_a = options === null || options === void 0 ? void 0 : options.apiKey) !== null && _a !== void 0 ? _a : resolveNugetApiKey(nugetPushSource);
16
+ const apiKey = resolveNugetApiKey(nugetPushSource);
18
17
  options = options || {};
19
18
  options.skipDuplicates = options.skipDuplicates === undefined
20
19
  ? env.resolveFlag("NUGET_IGNORE_DUPLICATE_PACKAGES")
@@ -502,6 +502,11 @@
502
502
  help: "Flag: should package version be incremented before packing?",
503
503
  default: "true"
504
504
  });
505
+ env.register({
506
+ name: "PACK_SYNC_PROJECT_VERSION",
507
+ help: "Flag: should the project version be synchronised with the package version when packing?",
508
+ default: "false"
509
+ });
505
510
  env.register({
506
511
  name: "PACK_INCREMENT_VERSION_BY",
507
512
  help: "Number (default 1): increment the selected version number by this value",
@@ -720,11 +725,6 @@
720
725
  help: "comma-delimited list of nuget sources if you don't want to use the defaults",
721
726
  default: env.resolve("NUGET_SOURCE")
722
727
  });
723
- env.register({
724
- name: "NUGET_PUSH_PACKAGES",
725
- help: "comma-delimited list of packages to push, either relative to the PACK_TARGET_FOLDER, or relative to the project root. If left empty, assume all packages under PACK_TARGET_FOLDER.",
726
- default: ""
727
- });
728
728
  env.register({
729
729
  name: "NUGET_PUSH_SOURCE",
730
730
  help: "Specifically: nuget source to push to. Will fall back on NUGET_SOURCE or first of NUGET_SOURCES.",
package/index.js CHANGED
@@ -1,372 +1,372 @@
1
- #!/usr/bin/env node
2
- // TODO: this file should be verified as having unix line-endings
3
-
4
- const requireModule = require("./gulp-tasks/modules/require-module");
5
- const { init } = requireModule("git-sha");
6
-
7
- const
8
- {
9
- FsEntities,
10
- stat,
11
- ls,
12
- readTextFile,
13
- fileExists,
14
- readTextFileLines,
15
- writeTextFile
16
- } = require("yafs"),
17
- log = require("./gulp-tasks/modules/log"),
18
- path = require("path"),
19
- debug = require("debug")("zarro::main"),
20
- ZarroError = require("./gulp-tasks/modules/zarro-error"),
21
- { skip } = require("./gulp-tasks/modules/linq"),
22
- gatherArgs = require("./index-modules/gather-args");
23
-
24
- function requireHandler(name) {
25
- const result = require(`./index-modules/handlers/${ name }`);
26
- return { ...result, name };
27
- }
28
-
29
- const handlers = [
30
- requireHandler("init"),
31
- requireHandler("help"),
32
- requireHandler("show-env"),
33
- requireHandler("create-task"),
34
- // must always come last as it will always volunteer to handle
35
- requireHandler("invoke-gulp")
36
- ];
37
-
38
- async function findHandlerFor(args) {
39
- for (let handler of handlers) {
40
- debug({
41
- label: "investigating handler",
42
- name: handler.name
43
- });
44
- if (await handler.test(args)) {
45
- debug(` -> invoking handler: ${ handler.name }`);
46
- return handler.handler;
47
- }
48
- }
49
- return null;
50
- }
51
-
52
- const defaultsFile = ".zarro-defaults";
53
-
54
- async function createZarroDefaultsEmpty() {
55
- await writeTextFile(defaultsFile, `# zarro defaults file:
56
- # place one VARIABLE=VALUE per line below
57
- # variables here will not override existing environment variables
58
- # unless prepended with a bang, ie
59
- # !VARIABLE=Value
60
- # so this means anything you set in your package.json, eg with
61
- # cross-env, will override what's in here unless you've specifically
62
- # marked the setting in here as forced with !
63
- `);
64
- }
65
-
66
- async function loadDefaults() {
67
- const
68
- exists = await fileExists(defaultsFile);
69
- if (!exists) {
70
- await createZarroDefaultsEmpty();
71
- return;
72
- }
73
- const
74
- lines = await readTextFileLines(defaultsFile);
75
- for (const line of lines) {
76
- const
77
- [ code, _ ] = splitComment(line);
78
- if (isEmpty(code)) {
79
- // comment-only line or empty line
80
- continue;
81
- }
82
- if (looksInvalid(code)) {
83
- log.warn(`invalid config line in ${ defaultsFile }:\n${ line }`);
84
- continue;
85
- }
86
- const
87
- parts = code.trim().split("="),
88
- name = parts[0],
89
- value = Array.from(skip(parts, 1)).join("="),
90
- forced = name[0] === '!',
91
- notYetSet = process.env[name] === undefined;
92
- if (notYetSet || forced) {
93
- const key = name.replace(/^!/, "");
94
- if (value) {
95
- debug(`setting env var ${ key } to '${ value }'`);
96
- process.env[key] = value;
97
- } else {
98
- debug(`deleting env var ${ key }`);
99
- delete process.env[key];
100
- }
101
- } else {
102
- debug(`env var ${ name } is already set, force it by setting !${ name }=${ value } in ${ defaultsFile }`)
103
- }
104
- }
105
- }
106
-
107
- function looksInvalid(code) {
108
- return (code || "").indexOf("=") === -1;
109
- }
110
-
111
- function isEmpty(text) {
112
- return (text || "").trim() === "";
113
- }
114
-
115
- function splitComment(line) {
116
- if (!line) {
117
- return [ "", "" ];
118
- }
119
- const idx = line.indexOf("#");
120
- if (idx === -1) {
121
- return [ line, "" ];
122
- }
123
- return [ line.substring(0, idx), line.substring(idx + 1) ];
124
- }
125
-
126
- async function transpileLocalTaskModules() {
127
- await Promise.all([
128
- transpileModulesUnder("local-tasks"),
129
- transpileModulesUnder("override-tasks")
130
- ]);
131
-
132
- const externalTaskFolders = await ls(
133
- "external-tasks", {
134
- entities: FsEntities.folders,
135
- recurse: false,
136
- fullPaths: true
137
- }
138
- ),
139
- promises = externalTaskFolders.map(
140
- f => transpileModulesUnder(f)
141
- );
142
- await Promise.all(promises);
143
- }
144
-
145
- async function transpileLocalTasks() {
146
- await Promise.all([
147
- transpileTasksUnder("local-tasks"),
148
- transpileTasksUnder("override-tasks")
149
- ]);
150
- const externalTaskFolders = await ls(
151
- "external-tasks", {
152
- entities: FsEntities.folders,
153
- recurse: false,
154
- fullPaths: true
155
- }
156
- ),
157
- promises = externalTaskFolders.map(
158
- f => transpileTasksUnder(f)
159
- );
160
- await Promise.all(promises);
161
- }
162
-
163
- async function transpileModulesUnder(folder) {
164
- await transpileTypeScriptFiles(
165
- path.join(folder, "modules"),
166
- true,
167
- s => s.replace(/\.ts$/, ".js")
168
- );
169
- }
170
-
171
- async function transpileTypeScriptFiles(
172
- inFolder,
173
- transpileAnyTypeScript,
174
- outputNameGenerator
175
- ) {
176
- const toTranspile = [];
177
- const fullPath = path.isAbsolute(inFolder)
178
- ? inFolder
179
- : path.join(process.cwd(), inFolder);
180
- const contents = await ls(fullPath, {
181
- recurse: false,
182
- entities: FsEntities.files,
183
- match: /\.ts$/,
184
- fullPaths: true
185
- });
186
- for (const item of contents) {
187
- toTranspile.push(item);
188
- }
189
-
190
- if (toTranspile.length === 0) {
191
- debug(`no typescript modules found; skipping transpile phase.`);
192
- return;
193
- }
194
-
195
- importTypeScript();
196
-
197
- try {
198
- const
199
- { ExecStepContext } = require("exec-step"),
200
- ctx = new ExecStepContext(),
201
- { transpileModule, ModuleKind } = require("typescript");
202
- for (const src of toTranspile) {
203
- if (!transpileAnyTypeScript) {
204
- const test = src.replace(/\.ts$/, ".js");
205
- if (await fileExists(test)) {
206
- // assume this is a compilation handled elsewhere
207
- continue;
208
- }
209
- }
210
- const output = outputNameGenerator(src);
211
- if (await fileExists(output)) {
212
- const srcStat = await stat(src);
213
- const outStat = await stat(output);
214
-
215
- const srcLastModified = srcStat.mtime.getTime();
216
- const outLastModified = outStat.mtime.getTime();
217
-
218
-
219
- if (srcLastModified <= outLastModified) {
220
- debug(`${ output } modified after ${ src }; skipping transpile`);
221
- continue;
222
- }
223
- debug(`will transpile: ${ src }`);
224
- }
225
- await ctx.exec(
226
- `transpiling ${ src }`,
227
- async () => {
228
- const contents = await readTextFile(src);
229
- const transpiled = transpileModule(contents, {
230
- compilerOptions: {
231
- esModuleInterop: true,
232
- module: ModuleKind.CommonJS,
233
- target: "es2017"
234
- }
235
- }).outputText;
236
- await writeTextFile(output, transpiled);
237
- }
238
- );
239
- }
240
- } catch (e) {
241
- log.error(`one or more typescript modules could not be transpiled:\n${ e }`);
242
- }
243
- }
244
-
245
- async function transpileTasksUnder(folder) {
246
- await transpileTypeScriptFiles(
247
- folder,
248
- false,
249
- s => s.replace(/\.ts$/, ".generated.js")
250
- );
251
- }
252
-
253
- function importTypeScript() {
254
- try {
255
- require("typescript");
256
- } catch (e) {
257
- const message = `TypeScript not installed, unable to transpile local tasks: \n- ${ toTranspile.join("\n -") }`;
258
- console.error(message);
259
- process.exit(2);
260
- }
261
- }
262
-
263
-
264
- async function transpileTasksUnder_(folder) {
265
- const toTranspile = [];
266
- const fullPath = path.isAbsolute(folder)
267
- ? folder
268
- : path.join(process.cwd(), folder);
269
- const contents = await ls(fullPath, {
270
- recurse: false,
271
- entities: FsEntities.files,
272
- match: /\.ts$/,
273
- fullPaths: true
274
- });
275
- for (const item of contents) {
276
- toTranspile.push(item);
277
- }
278
-
279
- if (toTranspile.length === 0) {
280
- debug(`no typescript modules found; skipping transpile phase.`);
281
- return;
282
- }
283
-
284
- importTypeScript();
285
-
286
- try {
287
- const
288
- { ExecStepContext } = require("exec-step"),
289
- ctx = new ExecStepContext(),
290
- { transpileModule, ModuleKind } = require("typescript");
291
- for (const src of toTranspile) {
292
- const test = src.replace(/\.ts$/, ".js");
293
- if (await fileExists(test)) {
294
- // assume this is a compilation handled elsewhere
295
- continue;
296
- }
297
- const output = src.replace(/\.ts$/, ".generated.js");
298
- if (await fileExists(output)) {
299
- const srcStat = await stat(src);
300
- const outStat = await stat(output);
301
-
302
- const srcLastModified = srcStat.mtime.getTime();
303
- const outLastModified = outStat.mtime.getTime();
304
-
305
-
306
- if (srcLastModified <= outLastModified) {
307
- debug(`${ output } modified after ${ src }; skipping transpile`);
308
- continue;
309
- }
310
- debug(`will transpile: ${ src }`);
311
- }
312
- await ctx.exec(
313
- `transpiling ${ src }`,
314
- async () => {
315
- const contents = await readTextFile(src);
316
- const transpiled = transpileModule(contents, {
317
- compilerOptions: {
318
- esModuleInterop: true,
319
- module: ModuleKind.CommonJS,
320
- target: "es2017"
321
- }
322
- }).outputText;
323
- await writeTextFile(output, transpiled);
324
- }
325
- );
326
- }
327
- } catch (e) {
328
- log.error(`one or more typescript modules could not be transpiled:\n${ e }`);
329
- }
330
- }
331
-
332
- (async function () {
333
- try {
334
- const rawArgs = await gatherArgs([ path.join(path.dirname(__dirname), ".bin", "zarro"), __filename ]);
335
- const args = [];
336
- let shouldChangeDir = false;
337
- for (const arg of rawArgs) {
338
- if (arg === "--in") {
339
- shouldChangeDir = true;
340
- continue;
341
- }
342
- if (shouldChangeDir) {
343
- log.info(` --- running in ${ arg } ---`);
344
- process.chdir(arg);
345
- shouldChangeDir = false;
346
- continue;
347
- }
348
- args.push(arg);
349
- }
350
- await Promise.all([
351
- loadDefaults(),
352
- init()
353
- ]);
354
- await Promise.all([
355
- transpileLocalTaskModules(),
356
- transpileLocalTasks()
357
- ]);
358
- const handler = await findHandlerFor(args);
359
- if (!handler) {
360
- throw new ZarroError("no handler for current args");
361
- }
362
- if (typeof handler !== "function") {
363
- throw new ZarroError(`handler for ${ JSON.stringify(args) } is not a function?!`);
364
- }
365
- await handler(args);
366
- } catch (e) {
367
- debug(e.stack || e);
368
- process.exit(1);
369
- }
370
- })();
371
-
372
-
1
+ #!/usr/bin/env node
2
+ // TODO: this file should be verified as having unix line-endings
3
+
4
+ const requireModule = require("./gulp-tasks/modules/require-module");
5
+ const { init } = requireModule("git-sha");
6
+
7
+ const
8
+ {
9
+ FsEntities,
10
+ stat,
11
+ ls,
12
+ readTextFile,
13
+ fileExists,
14
+ readTextFileLines,
15
+ writeTextFile
16
+ } = require("yafs"),
17
+ log = require("./gulp-tasks/modules/log"),
18
+ path = require("path"),
19
+ debug = require("debug")("zarro::main"),
20
+ ZarroError = require("./gulp-tasks/modules/zarro-error"),
21
+ { skip } = require("./gulp-tasks/modules/linq"),
22
+ gatherArgs = require("./index-modules/gather-args");
23
+
24
+ function requireHandler(name) {
25
+ const result = require(`./index-modules/handlers/${ name }`);
26
+ return { ...result, name };
27
+ }
28
+
29
+ const handlers = [
30
+ requireHandler("init"),
31
+ requireHandler("help"),
32
+ requireHandler("show-env"),
33
+ requireHandler("create-task"),
34
+ // must always come last as it will always volunteer to handle
35
+ requireHandler("invoke-gulp")
36
+ ];
37
+
38
+ async function findHandlerFor(args) {
39
+ for (let handler of handlers) {
40
+ debug({
41
+ label: "investigating handler",
42
+ name: handler.name
43
+ });
44
+ if (await handler.test(args)) {
45
+ debug(` -> invoking handler: ${ handler.name }`);
46
+ return handler.handler;
47
+ }
48
+ }
49
+ return null;
50
+ }
51
+
52
+ const defaultsFile = ".zarro-defaults";
53
+
54
+ async function createZarroDefaultsEmpty() {
55
+ await writeTextFile(defaultsFile, `# zarro defaults file:
56
+ # place one VARIABLE=VALUE per line below
57
+ # variables here will not override existing environment variables
58
+ # unless prepended with a bang, ie
59
+ # !VARIABLE=Value
60
+ # so this means anything you set in your package.json, eg with
61
+ # cross-env, will override what's in here unless you've specifically
62
+ # marked the setting in here as forced with !
63
+ `);
64
+ }
65
+
66
+ async function loadDefaults() {
67
+ const
68
+ exists = await fileExists(defaultsFile);
69
+ if (!exists) {
70
+ await createZarroDefaultsEmpty();
71
+ return;
72
+ }
73
+ const
74
+ lines = await readTextFileLines(defaultsFile);
75
+ for (const line of lines) {
76
+ const
77
+ [ code, _ ] = splitComment(line);
78
+ if (isEmpty(code)) {
79
+ // comment-only line or empty line
80
+ continue;
81
+ }
82
+ if (looksInvalid(code)) {
83
+ log.warn(`invalid config line in ${ defaultsFile }:\n${ line }`);
84
+ continue;
85
+ }
86
+ const
87
+ parts = code.trim().split("="),
88
+ name = parts[0],
89
+ value = Array.from(skip(parts, 1)).join("="),
90
+ forced = name[0] === '!',
91
+ notYetSet = process.env[name] === undefined;
92
+ if (notYetSet || forced) {
93
+ const key = name.replace(/^!/, "");
94
+ if (value) {
95
+ debug(`setting env var ${ key } to '${ value }'`);
96
+ process.env[key] = value;
97
+ } else {
98
+ debug(`deleting env var ${ key }`);
99
+ delete process.env[key];
100
+ }
101
+ } else {
102
+ debug(`env var ${ name } is already set, force it by setting !${ name }=${ value } in ${ defaultsFile }`)
103
+ }
104
+ }
105
+ }
106
+
107
+ function looksInvalid(code) {
108
+ return (code || "").indexOf("=") === -1;
109
+ }
110
+
111
+ function isEmpty(text) {
112
+ return (text || "").trim() === "";
113
+ }
114
+
115
+ function splitComment(line) {
116
+ if (!line) {
117
+ return [ "", "" ];
118
+ }
119
+ const idx = line.indexOf("#");
120
+ if (idx === -1) {
121
+ return [ line, "" ];
122
+ }
123
+ return [ line.substring(0, idx), line.substring(idx + 1) ];
124
+ }
125
+
126
+ async function transpileLocalTaskModules() {
127
+ await Promise.all([
128
+ transpileModulesUnder("local-tasks"),
129
+ transpileModulesUnder("override-tasks")
130
+ ]);
131
+
132
+ const externalTaskFolders = await ls(
133
+ "external-tasks", {
134
+ entities: FsEntities.folders,
135
+ recurse: false,
136
+ fullPaths: true
137
+ }
138
+ ),
139
+ promises = externalTaskFolders.map(
140
+ f => transpileModulesUnder(f)
141
+ );
142
+ await Promise.all(promises);
143
+ }
144
+
145
+ async function transpileLocalTasks() {
146
+ await Promise.all([
147
+ transpileTasksUnder("local-tasks"),
148
+ transpileTasksUnder("override-tasks")
149
+ ]);
150
+ const externalTaskFolders = await ls(
151
+ "external-tasks", {
152
+ entities: FsEntities.folders,
153
+ recurse: false,
154
+ fullPaths: true
155
+ }
156
+ ),
157
+ promises = externalTaskFolders.map(
158
+ f => transpileTasksUnder(f)
159
+ );
160
+ await Promise.all(promises);
161
+ }
162
+
163
+ async function transpileModulesUnder(folder) {
164
+ await transpileTypeScriptFiles(
165
+ path.join(folder, "modules"),
166
+ true,
167
+ s => s.replace(/\.ts$/, ".js")
168
+ );
169
+ }
170
+
171
+ async function transpileTypeScriptFiles(
172
+ inFolder,
173
+ transpileAnyTypeScript,
174
+ outputNameGenerator
175
+ ) {
176
+ const toTranspile = [];
177
+ const fullPath = path.isAbsolute(inFolder)
178
+ ? inFolder
179
+ : path.join(process.cwd(), inFolder);
180
+ const contents = await ls(fullPath, {
181
+ recurse: false,
182
+ entities: FsEntities.files,
183
+ match: /\.ts$/,
184
+ fullPaths: true
185
+ });
186
+ for (const item of contents) {
187
+ toTranspile.push(item);
188
+ }
189
+
190
+ if (toTranspile.length === 0) {
191
+ debug(`no typescript modules found; skipping transpile phase.`);
192
+ return;
193
+ }
194
+
195
+ importTypeScript();
196
+
197
+ try {
198
+ const
199
+ { ExecStepContext } = require("exec-step"),
200
+ ctx = new ExecStepContext(),
201
+ { transpileModule, ModuleKind } = require("typescript");
202
+ for (const src of toTranspile) {
203
+ if (!transpileAnyTypeScript) {
204
+ const test = src.replace(/\.ts$/, ".js");
205
+ if (await fileExists(test)) {
206
+ // assume this is a compilation handled elsewhere
207
+ continue;
208
+ }
209
+ }
210
+ const output = outputNameGenerator(src);
211
+ if (await fileExists(output)) {
212
+ const srcStat = await stat(src);
213
+ const outStat = await stat(output);
214
+
215
+ const srcLastModified = srcStat.mtime.getTime();
216
+ const outLastModified = outStat.mtime.getTime();
217
+
218
+
219
+ if (srcLastModified <= outLastModified) {
220
+ debug(`${ output } modified after ${ src }; skipping transpile`);
221
+ continue;
222
+ }
223
+ debug(`will transpile: ${ src }`);
224
+ }
225
+ await ctx.exec(
226
+ `transpiling ${ src }`,
227
+ async () => {
228
+ const contents = await readTextFile(src);
229
+ const transpiled = transpileModule(contents, {
230
+ compilerOptions: {
231
+ esModuleInterop: true,
232
+ module: ModuleKind.CommonJS,
233
+ target: "es2017"
234
+ }
235
+ }).outputText;
236
+ await writeTextFile(output, transpiled);
237
+ }
238
+ );
239
+ }
240
+ } catch (e) {
241
+ log.error(`one or more typescript modules could not be transpiled:\n${ e }`);
242
+ }
243
+ }
244
+
245
+ async function transpileTasksUnder(folder) {
246
+ await transpileTypeScriptFiles(
247
+ folder,
248
+ false,
249
+ s => s.replace(/\.ts$/, ".generated.js")
250
+ );
251
+ }
252
+
253
+ function importTypeScript() {
254
+ try {
255
+ require("typescript");
256
+ } catch (e) {
257
+ const message = `TypeScript not installed, unable to transpile local tasks: \n- ${ toTranspile.join("\n -") }`;
258
+ console.error(message);
259
+ process.exit(2);
260
+ }
261
+ }
262
+
263
+
264
+ async function transpileTasksUnder_(folder) {
265
+ const toTranspile = [];
266
+ const fullPath = path.isAbsolute(folder)
267
+ ? folder
268
+ : path.join(process.cwd(), folder);
269
+ const contents = await ls(fullPath, {
270
+ recurse: false,
271
+ entities: FsEntities.files,
272
+ match: /\.ts$/,
273
+ fullPaths: true
274
+ });
275
+ for (const item of contents) {
276
+ toTranspile.push(item);
277
+ }
278
+
279
+ if (toTranspile.length === 0) {
280
+ debug(`no typescript modules found; skipping transpile phase.`);
281
+ return;
282
+ }
283
+
284
+ importTypeScript();
285
+
286
+ try {
287
+ const
288
+ { ExecStepContext } = require("exec-step"),
289
+ ctx = new ExecStepContext(),
290
+ { transpileModule, ModuleKind } = require("typescript");
291
+ for (const src of toTranspile) {
292
+ const test = src.replace(/\.ts$/, ".js");
293
+ if (await fileExists(test)) {
294
+ // assume this is a compilation handled elsewhere
295
+ continue;
296
+ }
297
+ const output = src.replace(/\.ts$/, ".generated.js");
298
+ if (await fileExists(output)) {
299
+ const srcStat = await stat(src);
300
+ const outStat = await stat(output);
301
+
302
+ const srcLastModified = srcStat.mtime.getTime();
303
+ const outLastModified = outStat.mtime.getTime();
304
+
305
+
306
+ if (srcLastModified <= outLastModified) {
307
+ debug(`${ output } modified after ${ src }; skipping transpile`);
308
+ continue;
309
+ }
310
+ debug(`will transpile: ${ src }`);
311
+ }
312
+ await ctx.exec(
313
+ `transpiling ${ src }`,
314
+ async () => {
315
+ const contents = await readTextFile(src);
316
+ const transpiled = transpileModule(contents, {
317
+ compilerOptions: {
318
+ esModuleInterop: true,
319
+ module: ModuleKind.CommonJS,
320
+ target: "es2017"
321
+ }
322
+ }).outputText;
323
+ await writeTextFile(output, transpiled);
324
+ }
325
+ );
326
+ }
327
+ } catch (e) {
328
+ log.error(`one or more typescript modules could not be transpiled:\n${ e }`);
329
+ }
330
+ }
331
+
332
+ (async function () {
333
+ try {
334
+ const rawArgs = await gatherArgs([ path.join(path.dirname(__dirname), ".bin", "zarro"), __filename ]);
335
+ const args = [];
336
+ let shouldChangeDir = false;
337
+ for (const arg of rawArgs) {
338
+ if (arg === "--in") {
339
+ shouldChangeDir = true;
340
+ continue;
341
+ }
342
+ if (shouldChangeDir) {
343
+ log.info(` --- running in ${ arg } ---`);
344
+ process.chdir(arg);
345
+ shouldChangeDir = false;
346
+ continue;
347
+ }
348
+ args.push(arg);
349
+ }
350
+ await Promise.all([
351
+ loadDefaults(),
352
+ init()
353
+ ]);
354
+ await Promise.all([
355
+ transpileLocalTaskModules(),
356
+ transpileLocalTasks()
357
+ ]);
358
+ const handler = await findHandlerFor(args);
359
+ if (!handler) {
360
+ throw new ZarroError("no handler for current args");
361
+ }
362
+ if (typeof handler !== "function") {
363
+ throw new ZarroError(`handler for ${ JSON.stringify(args) } is not a function?!`);
364
+ }
365
+ await handler(args);
366
+ } catch (e) {
367
+ debug(e.stack || e);
368
+ process.exit(1);
369
+ }
370
+ })();
371
+
372
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zarro",
3
- "version": "1.168.2",
3
+ "version": "1.168.3",
4
4
  "description": "Some glue to make gulp easier, perhaps even zero- or close-to-zero-conf",
5
5
  "bin": {
6
6
  "zarro": "./index.js"
@@ -13,7 +13,7 @@
13
13
  "verify-submodules": "node index.js verify-submodules",
14
14
  "verify-no-debugger": "node index.js @",
15
15
  "clean-cache": "rimraf .jest-cache",
16
- "pretest": "run-s clean-cache build",
16
+ "pretest": "run-s clean-cache build verify-submodules",
17
17
  "test": "jest",
18
18
  "quick-test": "jest -o --no-cache",
19
19
  "clear-console": "console-cls",
package/types.d.ts CHANGED
@@ -355,10 +355,6 @@ declare global {
355
355
  license: LicenseIdentifier
356
356
  }
357
357
 
358
- interface ResolveNugetPushPackageFiles {
359
- resolveNugetPushPackageFiles: () => Promise<string[]>;
360
- }
361
-
362
358
  type ResolveMasks = (
363
359
  includeVar: StringEnvVar | StringEnvVar[],
364
360
  excludeVar: StringEnvVar | StringEnvVar[],
@@ -409,7 +405,6 @@ declare global {
409
405
  "NUGET_PUSH_SOURCE" |
410
406
  "NUGET_SOURCE" |
411
407
  "NUGET_SOURCES" |
412
- "NUGET_PUSH_PACKAGES" |
413
408
  "DOTNET_PUBLISH_RUNTIMES" |
414
409
  "DOTNET_PUBLISH_BUILD_CONFIGURATION" |
415
410
  "DOTNET_PUBLISH_OS" |
@@ -486,6 +481,7 @@ declare global {
486
481
  "NO_COLOR" |
487
482
  "NUGET_IGNORE_DUPLICATE_PACKAGES" |
488
483
  "PACK_INCREMENT_VERSION" |
484
+ "PACK_SYNC_PROJECT_VERSION" |
489
485
  "PACK_INCLUDE_EMPTY_DIRECTORIES" |
490
486
  "PACK_INCLUDE_SYMBOLS" |
491
487
  "PACK_INCLUDE_SOURCE" |
@@ -604,7 +600,6 @@ declare global {
604
600
  NUGET_PUSH_SOURCE: StringEnvVar;
605
601
  NUGET_SOURCES: StringEnvVar;
606
602
  NUGET_SOURCE: StringEnvVar;
607
- NUGET_PUSH_PACKAGES: StringEnvVar;
608
603
  DOTNET_PUBLISH_RUNTIMES: StringEnvVar;
609
604
  DOTNET_PUBLISH_BUILD_CONFIGURATION: StringEnvVar;
610
605
  DOTNET_PUBLISH_OS: StringEnvVar;
@@ -662,6 +657,7 @@ declare global {
662
657
  NO_COLOR: FlagEnvVar;
663
658
  NUGET_IGNORE_DUPLICATE_PACKAGES: FlagEnvVar;
664
659
  PACK_INCREMENT_VERSION: FlagEnvVar;
660
+ PACK_SYNC_PROJECT_VERSION: FlagEnvVar;
665
661
  PACK_INCLUDE_EMPTY_DIRECTORIES: FlagEnvVar;
666
662
  PACK_INCLUDE_SYMBOLS: FlagEnvVar;
667
663
  PACK_INCLUDE_SOURCE: FlagEnvVar;
@@ -748,7 +744,7 @@ declare global {
748
744
  type ReadPackageVersion = (packageJsonPath?: string) => Promise<string | undefined>;
749
745
  type ReadNuspecVersion = (pathToNuspec: string) => Promise<string | undefined>;
750
746
  // FIXME: is this used anywhere? should be supplanted by csproj-utils
751
- type ReadCsProjVersion = (pathToCsProj: string) => string | undefined;
747
+ type ReadCsProjVersion = (pathToCsProj: string) => Promise<string | undefined>;
752
748
  type ReadCsProjPackageVersion = (pathToCsProj: string) => string | undefined;
753
749
  type GatherPaths = (pathSpecs: string | string[], throwForNoMatches?: boolean) => Promise<string[]>;
754
750
  type PromisifyStream = (stream: Stream) => Promise<void>;
@@ -845,7 +841,6 @@ declare global {
845
841
 
846
842
  export interface NugetPushOpts {
847
843
  skipDuplicates?: boolean;
848
- apiKey?: string
849
844
  }
850
845
 
851
846
  type IsWindows = () => boolean;
@@ -1,54 +0,0 @@
1
- "use strict";
2
- (function () {
3
- const { ls, FsEntities, fileExists } = require("yafs"), path = require("path");
4
- async function resolveNugetPushPackageFiles() {
5
- const env = requireModule("env"), packRoot = env.resolve(env.PACK_TARGET_FOLDER), pushMask = env.resolveArray(env.NUGET_PUSH_PACKAGES);
6
- if (pushMask.length === 0) {
7
- return await enumeratePackagesIn(packRoot);
8
- }
9
- const collected = [];
10
- for (const mask of pushMask) {
11
- const maskFiles = await findFilesFor(mask);
12
- collected.push(...maskFiles);
13
- }
14
- return collected;
15
- }
16
- async function findFilesFor(mask) {
17
- if (await fileExists(mask)) {
18
- return [path.resolve(mask)];
19
- }
20
- const env = requireModule("env"), maskContainer = path.dirname(mask), searchContainers = path.isAbsolute(mask)
21
- ? [maskContainer]
22
- : [maskContainer, `${env.resolve(env.PACK_TARGET_FOLDER)}/${maskContainer}`], files = await lsAll(searchContainers);
23
- const maskHasFolders = mask.includes("/") || mask.includes("\\"), leaf = path.basename(mask), start = leaf.startsWith("*") ? ".*" : "^", end = leaf.endsWith("*") ? ".*" : "", regexed = mask.replace(/\*/g, ".*").replace(/\\/g, "\\/"), nupkgRe = /\.nupkg$/i, maskRe = new RegExp(`${start}${regexed}${end}`);
24
- return files.filter((f) => {
25
- const toTest = maskHasFolders
26
- ? f
27
- : path.basename(f);
28
- return nupkgRe.test(toTest) && maskRe.test(toTest);
29
- });
30
- }
31
- async function lsAll(dirs) {
32
- const result = [];
33
- for (const dir of dirs) {
34
- const files = await ls(dir, {
35
- entities: FsEntities.files,
36
- recurse: false,
37
- fullPaths: true
38
- });
39
- result.push(...files);
40
- }
41
- return result;
42
- }
43
- async function enumeratePackagesIn(packRoot) {
44
- return await ls(packRoot, {
45
- entities: FsEntities.files,
46
- match: /\.nupkg$/,
47
- recurse: false,
48
- fullPaths: true
49
- });
50
- }
51
- module.exports = {
52
- resolveNugetPushPackageFiles
53
- };
54
- })();
@@ -1,11 +0,0 @@
1
- "use strict";
2
- (function () {
3
- const gulp = requireModule("gulp");
4
- gulp.task("nuget-push", async () => {
5
- const env = requireModule("env"), runInParallel = requireModule("run-in-parallel"), nugetPush = requireModule("nuget-push"), { resolveNugetPushPackageFiles } = requireModule("resolve-nuget-push-package-files"), packageFiles = await resolveNugetPushPackageFiles(), nugetSrc = env.resolve("NUGET_PUSH_SOURCE");
6
- const actions = packageFiles.map(file => {
7
- return async () => await nugetPush(file, nugetSrc);
8
- });
9
- await runInParallel(2, ...actions);
10
- });
11
- })();