@pi-r/gulp 0.6.4 → 0.6.6

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.
Files changed (4) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +6 -3
  3. package/index.js +17 -20
  4. package/package.json +3 -3
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 An Pham
1
+ Copyright 2024 An Pham
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
package/README.md CHANGED
@@ -1,7 +1,10 @@
1
- ### @pi-r/gulp
1
+ # @pi-r/gulp
2
2
 
3
- https://e-mc.readthedocs.io/en/latest/task/index.html
3
+ ## Documentation
4
4
 
5
- ### LICENSE
5
+ - [E-mc](https://e-mc.readthedocs.io/en/latest/task/index.html)
6
+ - [squared](https://squared.readthedocs.io)
7
+
8
+ ## LICENSE
6
9
 
7
10
  MIT
package/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  const path = require("path");
4
3
  const fs = require("fs");
5
4
  const child_process = require("child_process");
@@ -8,13 +7,13 @@ const which = require("which");
8
7
  const types_1 = require("@e-mc/types");
9
8
  const Task = require('@e-mc/task');
10
9
  const BIN_NPX = Task.sanitizeCmd(which.sync('npx', { nothrow: true }) || 'npx');
11
- const BIN_GULP = Task.sanitizeCmd(which.sync("gulp" /* STRINGS.MODULE_NAME */, { nothrow: true }) || '');
10
+ const BIN_GULP = Task.sanitizeCmd(which.sync("gulp", { nothrow: true }) || '');
12
11
  const REGEXP_TIMESTAMP = /^\[\d+:\d+:\d+\]$/;
13
12
  async function executeTasks(assets, preceding, host) {
14
13
  if (this.aborted) {
15
14
  return Promise.reject((0, types_1.createAbortError)());
16
15
  }
17
- return this.allSettled(this.collate(assets, preceding), ['Execute tasks', "gulp" /* STRINGS.MODULE_NAME */]).then(result => {
16
+ return this.allSettled(this.collate(assets, preceding), ['Execute tasks', "gulp"]).then(result => {
18
17
  if (host) {
19
18
  for (const output of result) {
20
19
  if (output.status === 'fulfilled') {
@@ -31,11 +30,10 @@ async function executeTasks(assets, preceding, host) {
31
30
  });
32
31
  }
33
32
  const normalizePath = (value) => process.platform === 'win32' ? '"' + value.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"' : Task.sanitizeArgs(value);
34
- // @ts-ignore
35
33
  class Gulp extends Task {
36
34
  constructor() {
37
35
  super(...arguments);
38
- this._moduleName = "gulp" /* STRINGS.MODULE_NAME */;
36
+ this._moduleName = "gulp";
39
37
  }
40
38
  static async finalize(instance, assets) {
41
39
  return executeTasks.call(instance, assets, false, this);
@@ -56,7 +54,7 @@ class Gulp extends Task {
56
54
  const origDir = path.dirname(localUri);
57
55
  const scheduled = new Set();
58
56
  for (let { task, handler, preceding } of item.tasks) {
59
- if (task && handler === "gulp" /* STRINGS.MODULE_NAME */ && !!preceding === isPreceding) {
57
+ if (task && handler === "gulp" && !!preceding === isPreceding) {
60
58
  let gulpfile = (0, types_1.isString)(task) ? username && (0, types_1.isObject)(settings.users) && settings.users[username]?.[task] || settings[task] : task, tasks, opts;
61
59
  if ((0, types_1.isObject)(gulpfile)) {
62
60
  ({ path: gulpfile, tasks, opts } = gulpfile);
@@ -72,7 +70,7 @@ class Gulp extends Task {
72
70
  }
73
71
  }
74
72
  catch (err) {
75
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 32 /* LOG_TYPE.FILE */);
73
+ this.writeFail(["Unable to write file", path.basename(localUri)], err, 32);
76
74
  continue;
77
75
  }
78
76
  let dirMap = taskMap.get(task);
@@ -91,7 +89,7 @@ class Gulp extends Task {
91
89
  if (!(0, types_1.isString)(task)) {
92
90
  task = gulpfile && path.basename(gulpfile);
93
91
  }
94
- this.writeFail(["Unable to perform task" /* ERR_MESSAGE.PERFORM_TASK */, task ? "gulp" /* STRINGS.MODULE_NAME */ + ': ' + task : ''], (0, types_1.errorMessage)(task || "gulp" /* STRINGS.MODULE_NAME */, "Unknown" /* ERR_MESSAGE.UNKNOWN */, username), 4 /* LOG_TYPE.PROCESS */);
92
+ this.writeFail(["Unable to perform task", task ? "gulp" + ': ' + task : ''], (0, types_1.errorMessage)(task || "gulp", "Unknown", username), 4);
95
93
  }
96
94
  }
97
95
  }
@@ -191,7 +189,7 @@ class Gulp extends Task {
191
189
  spawn(gulp, callback) {
192
190
  const { task, origDir, data } = gulp;
193
191
  const tempDir = this.getTempDir({ uuidDir: true });
194
- const writeError = (value, err, hint, type = 32 /* LOG_TYPE.FILE */) => {
192
+ const writeError = (value, err, hint, type = 32) => {
195
193
  if (err) {
196
194
  this.writeFail([value, hint || (this.moduleName + ': ' + task)], err, { type, startTime });
197
195
  }
@@ -201,7 +199,7 @@ class Gulp extends Task {
201
199
  }
202
200
  };
203
201
  if (!tempDir) {
204
- writeError("Unable to create temp directory" /* ERR_MESSAGE.TEMP_DIRECTORY */, null, this.getTempDir());
202
+ writeError("Unable to create temp directory", null, this.getTempDir());
205
203
  return;
206
204
  }
207
205
  const exec = this.settings.exec;
@@ -256,7 +254,7 @@ class Gulp extends Task {
256
254
  }
257
255
  const startTime = process.hrtime();
258
256
  const broadcastId = this.broadcastId;
259
- this.formatMessage(4 /* LOG_TYPE.PROCESS */, "gulp" /* STRINGS.MODULE_NAME */, ['Executing task...', task], gulpfile);
257
+ this.formatMessage(4, "gulp", ['Executing task...', task], gulpfile);
260
258
  Promise.all(items.map(async (src) => fs.promises.copyFile(src, path.join(tempDir, path.basename(src)))))
261
259
  .then(() => {
262
260
  try {
@@ -274,7 +272,7 @@ class Gulp extends Task {
274
272
  timeStamp = '';
275
273
  }
276
274
  };
277
- const { stdout, stderr } = child_process.spawn(BIN_GULP || BIN_NPX, args, { cwd: process.cwd(), shell: true, stdio: Task.hasLogType(32768 /* LOG_TYPE.STDOUT */) && !broadcastId ? 'inherit' : undefined, signal: this.signal, uid, gid })
275
+ const { stdout, stderr } = child_process.spawn(BIN_GULP || BIN_NPX, args, { cwd: process.cwd(), shell: true, stdio: Task.hasLogType(32768) && !broadcastId ? 'inherit' : undefined, signal: this.signal, uid, gid })
278
276
  .on('exit', code => {
279
277
  if (!code) {
280
278
  this.addLog(types_1.STATUS_TYPE.INFO, out);
@@ -303,14 +301,14 @@ class Gulp extends Task {
303
301
  --i;
304
302
  }
305
303
  else {
306
- this.writeFail(["Unable to rename file" /* ERR_MESSAGE.RENAME_FILE */, filename], err, 32 /* LOG_TYPE.FILE */);
304
+ this.writeFail(["Unable to rename file", filename], err, 32);
307
305
  }
308
306
  }
309
307
  }
310
- this.writeTimeProcess("gulp" /* STRINGS.MODULE_NAME */, task + ' -> ' + path.basename(items[0]), startTime);
308
+ this.writeTimeProcess("gulp", task + ' -> ' + path.basename(items[0]), startTime);
311
309
  }
312
310
  catch (err) {
313
- writeError("Unable to read directory" /* ERR_MESSAGE.READ_DIRECTORY */, err, false);
311
+ writeError("Unable to read directory", err, false);
314
312
  }
315
313
  items.forEach(value => !result.has(value) && (deleted || (deleted = [])).push(value));
316
314
  result.forEach(value => !items.includes(value) && (added || (added = [])).push(value));
@@ -318,10 +316,10 @@ class Gulp extends Task {
318
316
  callback({ added, deleted });
319
317
  }
320
318
  else {
321
- writeError("Unable to execute file" /* ERR_MESSAGE.EXECUTE_FILE */, new Error(message || "Unknown" /* ERR_MESSAGE.UNKNOWN */), '', 4 /* LOG_TYPE.PROCESS */);
319
+ writeError("Unable to execute file", new Error(message || "Unknown"), '', 4);
322
320
  }
323
321
  })
324
- .on('error', err => writeError("Unknown" /* ERR_MESSAGE.UNKNOWN */, err, false, 4 /* LOG_TYPE.PROCESS */));
322
+ .on('error', err => writeError("Unknown", err, false, 4));
325
323
  if (stdout) {
326
324
  stdout.setEncoding('utf-8').on('data', (value) => {
327
325
  if (broadcastId) {
@@ -340,11 +338,10 @@ class Gulp extends Task {
340
338
  }
341
339
  }
342
340
  catch (err) {
343
- writeError("Unable to execute file" /* ERR_MESSAGE.EXECUTE_FILE */, err);
341
+ writeError("Unable to execute file", err);
344
342
  }
345
343
  })
346
- .catch(err => writeError("Unable to copy file" /* ERR_MESSAGE.COPY_FILE */, err, tempDir));
344
+ .catch(err => writeError("Unable to copy file", err, tempDir));
347
345
  }
348
346
  }
349
-
350
347
  module.exports = Gulp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/gulp",
3
- "version": "0.6.4",
3
+ "version": "0.6.6",
4
4
  "description": "Gulp task constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -20,8 +20,8 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/pi-r#readme",
22
22
  "dependencies": {
23
- "@e-mc/task": "^0.8.4",
24
- "@e-mc/types": "^0.8.4",
23
+ "@e-mc/task": "^0.8.7",
24
+ "@e-mc/types": "^0.8.7",
25
25
  "gulp": "^4.0.2",
26
26
  "gulp-cli": "^2.3.0",
27
27
  "strip-ansi": "6.0.1",