@pi-r/gulp 0.5.1 → 0.5.2

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 +4 -2
  3. package/index.js +21 -18
  4. package/package.json +4 -4
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 An Pham
1
+ Copyright 2023 Wit Studio
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,5 +1,7 @@
1
- ### @pi-r/gulp
1
+ # @pi-r/gulp
2
2
 
3
- ### LICENSE
3
+ PEP 402 - Forever Vivy
4
+
5
+ ## LICENSE
4
6
 
5
7
  MIT
package/index.js CHANGED
@@ -8,13 +8,13 @@ const which = require("which");
8
8
  const types_1 = require("@e-mc/types");
9
9
  const Task = require('@e-mc/task');
10
10
  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 }) || '');
11
+ const BIN_GULP = Task.sanitizeCmd(which.sync("gulp", { nothrow: true }) || '');
12
12
  const REGEXP_TIMESTAMP = /^\[\d+:\d+:\d+\]$/;
13
13
  function executeTasks(assets, preceding, host) {
14
14
  if (this.aborted) {
15
15
  return Promise.reject((0, types_1.createAbortError)());
16
16
  }
17
- return this.allSettled(this.collate(assets, preceding), ['Execute tasks', "gulp" /* STRINGS.MODULE_NAME */]).then(result => {
17
+ return this.allSettled(this.collate(assets, preceding), ['Execute tasks', "gulp"]).then(result => {
18
18
  if (host) {
19
19
  for (const output of result) {
20
20
  if (output.status === 'fulfilled') {
@@ -31,11 +31,10 @@ function executeTasks(assets, preceding, host) {
31
31
  });
32
32
  }
33
33
  const normalizePath = (value) => process.platform === 'win32' ? '"' + value.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"' : Task.sanitizeArgs(value);
34
- // @ts-ignore
35
34
  class Gulp extends Task {
36
35
  constructor() {
37
36
  super(...arguments);
38
- this._moduleName = "gulp" /* STRINGS.MODULE_NAME */;
37
+ this._moduleName = "gulp";
39
38
  }
40
39
  static finalize(instance, assets) {
41
40
  return executeTasks.call(instance, assets, false, this);
@@ -56,7 +55,7 @@ class Gulp extends Task {
56
55
  const origDir = path.dirname(localUri);
57
56
  const scheduled = new Set();
58
57
  for (let { task, handler, preceding } of item.tasks) {
59
- if (task && handler === "gulp" /* STRINGS.MODULE_NAME */ && !!preceding === isPreceding) {
58
+ if (task && handler === "gulp" && !!preceding === isPreceding) {
60
59
  let gulpfile = (0, types_1.isString)(task) ? username && (0, types_1.isObject)(settings.users) && settings.users[username]?.[task] || settings[task] : task, tasks, opts;
61
60
  if ((0, types_1.isObject)(gulpfile)) {
62
61
  ({ path: gulpfile, tasks, opts } = gulpfile);
@@ -81,7 +80,7 @@ class Gulp extends Task {
81
80
  if (!(0, types_1.isString)(task)) {
82
81
  task = gulpfile && path.basename(gulpfile);
83
82
  }
84
- 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 */);
83
+ this.writeFail(["Unable to perform task", task ? "gulp" + ': ' + task : ''], (0, types_1.errorMessage)(task || "gulp", "Unknown", username), 4);
85
84
  }
86
85
  }
87
86
  }
@@ -181,7 +180,7 @@ class Gulp extends Task {
181
180
  spawn(gulp, callback) {
182
181
  const { task, origDir, data } = gulp;
183
182
  const tempDir = this.getTempDir({ uuidDir: true });
184
- const writeError = (value, err, hint, type = 32 /* LOG_TYPE.FILE */) => {
183
+ const writeError = (value, err, hint, type = 32) => {
185
184
  if (err) {
186
185
  this.writeFail([value, hint || (this.moduleName + ': ' + task)], err, { type, startTime });
187
186
  }
@@ -191,7 +190,7 @@ class Gulp extends Task {
191
190
  }
192
191
  };
193
192
  if (!tempDir) {
194
- writeError("Unable to create temp directory" /* ERR_MESSAGE.TEMP_DIRECTORY */, null, this.getTempDir());
193
+ writeError("Unable to create temp directory", null, this.getTempDir());
195
194
  return;
196
195
  }
197
196
  const exec = this.settings.exec;
@@ -246,7 +245,7 @@ class Gulp extends Task {
246
245
  }
247
246
  const startTime = process.hrtime();
248
247
  const broadcastId = this.broadcastId;
249
- this.formatMessage(4 /* LOG_TYPE.PROCESS */, "gulp" /* STRINGS.MODULE_NAME */, ['Executing task...', task], gulpfile);
248
+ this.formatMessage(4, "gulp", ['Executing task...', task], gulpfile);
250
249
  Promise.all(items.map(src => fs.promises.copyFile(src, path.join(tempDir, path.basename(src)))))
251
250
  .then(() => {
252
251
  try {
@@ -264,7 +263,7 @@ class Gulp extends Task {
264
263
  timeStamp = '';
265
264
  }
266
265
  };
267
- 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 })
266
+ 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 })
268
267
  .on('exit', code => {
269
268
  if (!code) {
270
269
  this.addLog(types_1.STATUS_TYPE.INFO, out);
@@ -293,14 +292,14 @@ class Gulp extends Task {
293
292
  --i;
294
293
  }
295
294
  else {
296
- this.writeFail(["Unable to rename file" /* ERR_MESSAGE.RENAME_FILE */, filename], err, 32 /* LOG_TYPE.FILE */);
295
+ this.writeFail(["Unable to rename file", filename], err, 32);
297
296
  }
298
297
  }
299
298
  }
300
- this.writeTimeProcess("gulp" /* STRINGS.MODULE_NAME */, task + ' -> ' + path.basename(items[0]), startTime);
299
+ this.writeTimeProcess("gulp", task + ' -> ' + path.basename(items[0]), startTime);
301
300
  }
302
301
  catch (err) {
303
- writeError("Unable to read directory" /* ERR_MESSAGE.READ_DIRECTORY */, err, false);
302
+ writeError("Unable to read directory", err, false);
304
303
  }
305
304
  items.forEach(value => !result.has(value) && (deleted || (deleted = [])).push(value));
306
305
  result.forEach(value => !items.includes(value) && (added || (added = [])).push(value));
@@ -308,10 +307,10 @@ class Gulp extends Task {
308
307
  callback({ added, deleted });
309
308
  }
310
309
  else {
311
- writeError("Unable to execute file" /* ERR_MESSAGE.EXECUTE_FILE */, new Error(message || "Unknown" /* ERR_MESSAGE.UNKNOWN */), '', 4 /* LOG_TYPE.PROCESS */);
310
+ writeError("Unable to execute file", new Error(message || "Unknown"), '', 4);
312
311
  }
313
312
  })
314
- .on('error', err => writeError("Unknown" /* ERR_MESSAGE.UNKNOWN */, err, false, 4 /* LOG_TYPE.PROCESS */));
313
+ .on('error', err => writeError("Unknown", err, false, 4));
315
314
  if (stdout) {
316
315
  stdout.setEncoding('utf-8').on('data', (value) => {
317
316
  if (broadcastId) {
@@ -330,11 +329,15 @@ class Gulp extends Task {
330
329
  }
331
330
  }
332
331
  catch (err) {
333
- writeError("Unable to execute file" /* ERR_MESSAGE.EXECUTE_FILE */, err);
332
+ writeError("Unable to execute file", err);
334
333
  }
335
334
  })
336
- .catch(err => writeError("Unable to copy file" /* ERR_MESSAGE.COPY_FILE */, err, tempDir));
335
+ .catch(err => writeError("Unable to copy file", err, tempDir));
337
336
  }
338
337
  }
338
+ exports.default = Gulp;
339
339
 
340
- module.exports = Gulp;
340
+ if (exports.default) {
341
+ module.exports = exports.default;
342
+ module.exports.default = exports.default;
343
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/gulp",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Gulp task constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/anpham6/pi-r.git",
11
+ "url": "git+https://github.com/anpham6/pi-r.git",
12
12
  "directory": "src/module/gulp"
13
13
  },
14
14
  "keywords": [
@@ -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.7.0",
24
- "@e-mc/types": "^0.7.0",
23
+ "@e-mc/task": "^0.7.2",
24
+ "@e-mc/types": "^0.7.2",
25
25
  "gulp": "^4.0.2",
26
26
  "gulp-cli": "^2.3.0",
27
27
  "strip-ansi": "6.0.1",