quackage 1.0.61 → 1.0.63

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.
@@ -70,7 +70,13 @@ console.log(` > Building to [${_CONFIG.LibraryUniminifiedFileName}] and [${_CO
70
70
  console.log(`--> Gulp is taking over!`);
71
71
 
72
72
  const libBrowserify = require('browserify');
73
- const libGulp = require('gulp');
73
+
74
+ // Resolve gulp from the consuming project's CWD so that the task
75
+ // registry is shared with the gulp CLI (which also resolves from CWD).
76
+ // Without this, `file:` dev-dependency references to quackage cause
77
+ // two separate gulp instances — tasks registered here become invisible
78
+ // to the CLI, resulting in "Task never defined: default".
79
+ const libGulp = require(require.resolve('gulp', { paths: [process.cwd()] }));
74
80
 
75
81
  const libVinylSourceStream = require('vinyl-source-stream');
76
82
  const libVinylBuffer = require('vinyl-buffer');
@@ -78,28 +84,74 @@ const libVinylBuffer = require('vinyl-buffer');
78
84
  const libSourcemaps = require('gulp-sourcemaps');
79
85
  const libBabel = require('gulp-babel');
80
86
  const libTerser = require('gulp-terser');
87
+ const { Transform } = require('stream');
88
+
89
+ /**
90
+ * Create a configured browserify instance with common settings.
91
+ *
92
+ * Applies:
93
+ * - BrowserifyIgnore entries from config
94
+ * - Global transform to rewrite `require('node:xxx')` → `require('xxx')`
95
+ * (needed for packages like find-my-way v9 that use Node.js prefixed builtins)
96
+ *
97
+ * @param {object} pConfig - The gulpfile config object
98
+ * @returns {object} Configured browserify instance
99
+ */
100
+ function createBrowserifyInstance(pConfig)
101
+ {
102
+ var tmpBrowserify = libBrowserify(
103
+ {
104
+ entries: pConfig.EntrypointInputSourceFile,
105
+ standalone: pConfig.LibraryObjectName,
106
+ debug: true
107
+ });
108
+
109
+ // Ignore modules that should not be bundled (e.g. WASM loaders loaded via <script> tag)
110
+ if (Array.isArray(pConfig.BrowserifyIgnore))
111
+ {
112
+ for (var i = 0; i < pConfig.BrowserifyIgnore.length; i++)
113
+ {
114
+ tmpBrowserify.ignore(pConfig.BrowserifyIgnore[i]);
115
+ }
116
+ }
117
+
118
+ // Global transform: rewrite require('node:xxx') → require('xxx')
119
+ // Some npm packages (e.g. find-my-way v9) use the `node:` prefix for
120
+ // built-in modules, which browserify cannot resolve. This transform
121
+ // strips the prefix so browserify resolves the standard module name.
122
+ tmpBrowserify.transform(
123
+ function(pFile)
124
+ {
125
+ var tmpChunks = [];
126
+ return new Transform(
127
+ {
128
+ transform: function(pChunk, pEncoding, fCallback)
129
+ {
130
+ tmpChunks.push(pChunk);
131
+ fCallback();
132
+ },
133
+ flush: function(fCallback)
134
+ {
135
+ var tmpSource = Buffer.concat(tmpChunks).toString('utf8');
136
+ tmpSource = tmpSource.replace(
137
+ /require\(\s*['"]node:([^'"]+)['"]\s*\)/g,
138
+ "require('$1')"
139
+ );
140
+ this.push(tmpSource);
141
+ fCallback();
142
+ }
143
+ });
144
+ },
145
+ { global: true }
146
+ );
147
+
148
+ return tmpBrowserify;
149
+ }
81
150
 
82
151
  // Build the module for the browser
83
152
  libGulp.task('minified',
84
153
  () => {
85
- // set up the custom browserify instance for this task
86
- var tmpBrowserify = libBrowserify(
87
- {
88
- entries: _CONFIG.EntrypointInputSourceFile,
89
- standalone: _CONFIG.LibraryObjectName,
90
- debug: true
91
- });
92
-
93
- // Ignore modules that should not be bundled (e.g. WASM loaders loaded via <script> tag)
94
- if (Array.isArray(_CONFIG.BrowserifyIgnore))
95
- {
96
- for (var i = 0; i < _CONFIG.BrowserifyIgnore.length; i++)
97
- {
98
- tmpBrowserify.ignore(_CONFIG.BrowserifyIgnore[i]);
99
- }
100
- }
101
-
102
- return tmpBrowserify.bundle()
154
+ return createBrowserifyInstance(_CONFIG).bundle()
103
155
  .pipe(libVinylSourceStream(_CONFIG.LibraryMinifiedFileName))
104
156
  .pipe(libVinylBuffer())
105
157
  .pipe(libSourcemaps.init({loadMaps: true}))
@@ -114,24 +166,7 @@ libGulp.task('minified',
114
166
  // Build the module for the browser
115
167
  libGulp.task('debug',
116
168
  () => {
117
- // set up the custom browserify instance for this task
118
- var tmpBrowserify = libBrowserify(
119
- {
120
- entries: _CONFIG.EntrypointInputSourceFile,
121
- standalone: _CONFIG.LibraryObjectName,
122
- debug: true
123
- });
124
-
125
- // Ignore modules that should not be bundled (e.g. WASM loaders loaded via <script> tag)
126
- if (Array.isArray(_CONFIG.BrowserifyIgnore))
127
- {
128
- for (var i = 0; i < _CONFIG.BrowserifyIgnore.length; i++)
129
- {
130
- tmpBrowserify.ignore(_CONFIG.BrowserifyIgnore[i]);
131
- }
132
- }
133
-
134
- return tmpBrowserify.bundle()
169
+ return createBrowserifyInstance(_CONFIG).bundle()
135
170
  .pipe(libVinylSourceStream(_CONFIG.LibraryUniminifiedFileName))
136
171
  .pipe(libVinylBuffer())
137
172
  .pipe(libSourcemaps.init({loadMaps: true}))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quackage",
3
- "version": "1.0.61",
3
+ "version": "1.0.63",
4
4
  "description": "Building. Testing. Quacking. Reloading.",
5
5
  "main": "source/Quackage-CLIProgram.js",
6
6
  "scripts": {
@@ -20,6 +20,7 @@ let _Pict = new libCLIProgram(
20
20
  require('./commands/Quackage-Command-UpdatePackage.js'),
21
21
  require('./commands/Quackage-Command-UpdatePackage-Luxury.js'),
22
22
  require('./commands/Quackage-Command-Lint.js'),
23
+ require('./commands/Quackage-Command-CheckDependencies.js'),
23
24
  require('./commands/Quackage-Command-UpdateNodeGitignore.js'),
24
25
 
25
26
  // Mocha test execution
@@ -69,7 +69,15 @@ class QuackageCommandBuild extends libCommandLineCommand
69
69
  }
70
70
 
71
71
  // ## .gulpfile-quackage-config.json
72
- libFS.writeFileSync(`${this.fable.AppData.CWD}/.gulpfile-quackage-config.json`, this.fable.parseTemplateByHash('Gulpfile-Configuration', pAction));
72
+ let tmpGulpfileConfigContent = this.fable.parseTemplateByHash('Gulpfile-Configuration', pAction);
73
+ // Allow per-action BrowserifyIgnore overrides from GulpExecutions entries
74
+ if (Array.isArray(pAction.BrowserifyIgnore) && pAction.BrowserifyIgnore.length > 0)
75
+ {
76
+ let tmpGulpfileConfig = JSON.parse(tmpGulpfileConfigContent);
77
+ tmpGulpfileConfig.BrowserifyIgnore = pAction.BrowserifyIgnore;
78
+ tmpGulpfileConfigContent = JSON.stringify(tmpGulpfileConfig, null, 4);
79
+ }
80
+ libFS.writeFileSync(`${this.fable.AppData.CWD}/.gulpfile-quackage-config.json`, tmpGulpfileConfigContent);
73
81
  // ## .gulpfile-quackage.js
74
82
  libFS.writeFileSync(`${this.fable.AppData.CWD}/.gulpfile-quackage.js`, this.fable.parseTemplateByHash('Gulpfile-QuackageBase', { AppData: this.fable.AppData, Record: pAction }));
75
83
  // ## gulpfile.js
@@ -0,0 +1,134 @@
1
+ const libCommandLineCommand = require('pict-service-commandlineutility').ServiceCommandLineCommand;
2
+ const libFS = require('fs');
3
+ const libPath = require('path');
4
+
5
+ class QuackageCommandCheckDependencies extends libCommandLineCommand
6
+ {
7
+ constructor(pFable, pManifest, pServiceHash)
8
+ {
9
+ super(pFable, pManifest, pServiceHash);
10
+
11
+ this.options.CommandKeyword = 'check-dependencies';
12
+ this.options.Description = 'Check package.json for local file:// references and list all dependency versions';
13
+ this.options.Aliases.push('check-deps');
14
+ this.options.Aliases.push('checkdeps');
15
+
16
+ this.options.CommandOptions.push({ Name: '-a, --allow-file-package-references', Description: 'Allow file:// references without returning an error exit code', Default: false });
17
+
18
+ this.addCommand();
19
+ }
20
+
21
+ onRunAsync(fCallback)
22
+ {
23
+ let tmpPackage = this.fable.AppData.Package;
24
+ let tmpCWD = this.fable.AppData.CWD;
25
+ let tmpAllowFileReferences = this.CommandOptions.allowFilePackageReferences ? true : false;
26
+
27
+ let tmpFileReferenceCount = 0;
28
+ let tmpMismatchCount = 0;
29
+
30
+ this.log.info(`Checking dependencies for ${tmpPackage.name}@${tmpPackage.version} ...`);
31
+
32
+ let tmpDependencySections = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
33
+
34
+ for (let i = 0; i < tmpDependencySections.length; i++)
35
+ {
36
+ let tmpSectionName = tmpDependencySections[i];
37
+
38
+ if (!tmpPackage.hasOwnProperty(tmpSectionName))
39
+ {
40
+ continue;
41
+ }
42
+
43
+ let tmpDependencies = tmpPackage[tmpSectionName];
44
+ let tmpDependencyNames = Object.keys(tmpDependencies);
45
+
46
+ if (tmpDependencyNames.length < 1)
47
+ {
48
+ continue;
49
+ }
50
+
51
+ console.log('');
52
+ this.log.info(`--- ${tmpSectionName} ---`);
53
+
54
+ for (let j = 0; j < tmpDependencyNames.length; j++)
55
+ {
56
+ let tmpDepName = tmpDependencyNames[j];
57
+ let tmpDepVersion = tmpDependencies[tmpDepName];
58
+ let tmpIsFileReference = (typeof(tmpDepVersion) === 'string') && tmpDepVersion.startsWith('file://');
59
+
60
+ // Try to read the installed version from node_modules
61
+ let tmpInstalledVersion = '(not installed)';
62
+ try
63
+ {
64
+ let tmpInstalledPackagePath = libPath.join(tmpCWD, 'node_modules', tmpDepName, 'package.json');
65
+ if (libFS.existsSync(tmpInstalledPackagePath))
66
+ {
67
+ let tmpInstalledPackage = JSON.parse(libFS.readFileSync(tmpInstalledPackagePath, 'utf8'));
68
+ tmpInstalledVersion = tmpInstalledPackage.version || '(unknown)';
69
+ }
70
+ }
71
+ catch (pError)
72
+ {
73
+ tmpInstalledVersion = '(error reading)';
74
+ }
75
+
76
+ let tmpVersionMatch = true;
77
+ // For non-file references, check if the installed version satisfies the specified range
78
+ if (!tmpIsFileReference && tmpInstalledVersion !== '(not installed)' && tmpInstalledVersion !== '(error reading)' && tmpInstalledVersion !== '(unknown)')
79
+ {
80
+ // Simple display check -- show mismatch if the specified version doesn't contain the installed version
81
+ // This is intentionally simple; a full semver check would require a library
82
+ if (tmpDepVersion !== tmpInstalledVersion && !tmpDepVersion.includes(tmpInstalledVersion))
83
+ {
84
+ tmpVersionMatch = false;
85
+ tmpMismatchCount++;
86
+ }
87
+ }
88
+
89
+ if (tmpIsFileReference)
90
+ {
91
+ tmpFileReferenceCount++;
92
+ this.log.warn(` [FILE REF] ${tmpDepName}: ${tmpDepVersion} --> installed: ${tmpInstalledVersion}`);
93
+ }
94
+ else if (!tmpVersionMatch)
95
+ {
96
+ this.log.info(` [MISMATCH] ${tmpDepName}: ${tmpDepVersion} --> installed: ${tmpInstalledVersion}`);
97
+ }
98
+ else
99
+ {
100
+ this.log.info(` [OK] ${tmpDepName}: ${tmpDepVersion} --> installed: ${tmpInstalledVersion}`);
101
+ }
102
+ }
103
+ }
104
+
105
+ console.log('');
106
+
107
+ if (tmpMismatchCount > 0)
108
+ {
109
+ this.log.warn(`Found ${tmpMismatchCount} version mismatch(es) between package.json and node_modules.`);
110
+ }
111
+
112
+ if (tmpFileReferenceCount > 0)
113
+ {
114
+ this.log.warn(`Found ${tmpFileReferenceCount} file:// reference(s) in package.json!`);
115
+ if (!tmpAllowFileReferences)
116
+ {
117
+ this.log.error(`Refusing to publish with local file:// references. Use --allow-file-package-references to override.`);
118
+ this.fable.QuackageProcess.exitParentProcess(1);
119
+ }
120
+ else
121
+ {
122
+ this.log.info(`File references allowed by --allow-file-package-references flag.`);
123
+ }
124
+ }
125
+ else
126
+ {
127
+ this.log.info(`No file:// references found. All clear for publishing!`);
128
+ }
129
+
130
+ return fCallback();
131
+ };
132
+ }
133
+
134
+ module.exports = QuackageCommandCheckDependencies;
@@ -43,7 +43,7 @@ class QuackageCommandCopyFilesFromTo extends libCommandLineCommand
43
43
  {
44
44
  let tmpErrorMessage = `Not even the git checkout location has an installation of copy-files-from-to at [${tmpCFFTLocation}]... building cannot commence. We also tried CWD [${tmpCWDCFFTLocation}] and relative node_modules [${tmpRelativePackageCFFTLocation}]. Sorry! Maybe you need to run "npm install" somewhere??`;
45
45
  this.log.info(tmpErrorMessage)
46
- return fActionCallback(new Error(tmpErrorMessage));
46
+ return fCallback(new Error(tmpErrorMessage));
47
47
  }
48
48
  this.log.info(`Quackage found copy-files-from-to at [${tmpCFFTLocation}] ... executing build from there.`);
49
49
 
@@ -44,7 +44,7 @@ class QuackageCommandBuild extends libCommandLineCommand
44
44
  {
45
45
  let tmpErrorMessage = `Not even the git checkout location has an installation of mocha at [${tmpMochaLocation}]... building cannot commence. We also tried CWD [${tmpCWDMochaLocation}] and relative node_modules [${tmpRelativePackageMochaLocation}]. Sorry! Maybe you need to run "npm install" somewhere??`;
46
46
  this.log.info(tmpErrorMessage)
47
- return fActionCallback(new Error(tmpErrorMessage));
47
+ return fCallback(new Error(tmpErrorMessage));
48
48
  }
49
49
  this.log.info(`Quackage found mocha at [${tmpMochaLocation}] ... executing build from there.`);
50
50