@ibgib/web-gib 0.0.32 → 0.0.34

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.
@@ -10,5 +10,5 @@
10
10
  /**
11
11
  * this is the version of this package, auto-updated in the build process
12
12
  */
13
- export declare const AUTO_GENERATED_VERSION = "0.0.32";
13
+ export declare const AUTO_GENERATED_VERSION = "0.0.34";
14
14
  //# sourceMappingURL=AUTO-GENERATED-version.d.mts.map
@@ -10,5 +10,5 @@
10
10
  /**
11
11
  * this is the version of this package, auto-updated in the build process
12
12
  */
13
- export const AUTO_GENERATED_VERSION = '0.0.32';
13
+ export const AUTO_GENERATED_VERSION = '0.0.34';
14
14
  //# sourceMappingURL=AUTO-GENERATED-version.mjs.map
@@ -1,213 +1,4 @@
1
- import { readdir, open } from 'node:fs/promises';
2
- import { pathToFileURL } from 'node:url';
3
- import { statSync } from 'node:fs';
4
- import * as pathUtils from 'path';
5
- import { pretty } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
6
- import { getGlobalRespecGib } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
7
- // #region settings
8
- /**
9
- * This is how I enable/disable verbose logging. Do with it what you will.
10
- */
11
- const logalot = false;
12
- /** set this to the root of the respecs to look at */
13
- const RESPEC_ROOT_DIR_RELATIVE_TO_BASE = './dist';
14
- /** change this to suit your naming convention */
15
- const RESPEC_FILE_REG_EXP = /^.+respec\.mjs$/;
16
- // const RESPEC_FILE_REG_EXP = /^.*respec-gib.respec\.mjs$/;
17
- // if (respecPath.includes('respec-gib.respec.mjs')) {
18
- /**
19
- * If on, will first load a file and see if there is an extra respecful
20
- * `await respecfully`/`ifWe` block. Use these if you want to focus on a single or
21
- * subset of respecs.
22
- *
23
- * If there are no extra respecful blocks found in an entire file, that file
24
- * will be skipped.
25
- *
26
- * Note: this only is a flag to search through respec files.
27
- */
28
- const LOOK_FOR_EXTRA_RESPEC = true;
29
- /**
30
- * The names of the functions that indicate that we want to focus on just those
31
- * blocks.
32
- *
33
- * ATOW, for first run implementation here, I am implementing it such that it
34
- * will filter out files that don't have these indicators. The respec files that
35
- * do have these will execute fully, but the output will only include these
36
- * particular blocks.
37
- */
38
- const EXTRA_RESPEC_FUNCTION_NAMES = ['await respecfullyDear', 'ifWeMight'];
39
- // #endregion settings
40
- // #region 1. get respec paths
41
- const basePath = process.cwd();
42
- const srcPath = pathUtils.join(basePath, RESPEC_ROOT_DIR_RELATIVE_TO_BASE);
43
- if (logalot) {
44
- console.log(`cwd: ${process.cwd()}`);
45
- }
46
- if (logalot) {
47
- console.log(`basePath: ${basePath}`);
48
- }
49
- if (logalot) {
50
- console.log(`srcPath: ${srcPath}`);
51
- }
52
- const respecGib = getGlobalRespecGib();
53
- const allRespecPaths = await getRespecFileFullPaths(srcPath, []);
54
- if (logalot) {
55
- console.log(`allRespecPaths: ${allRespecPaths} (I: f5182a455375a8cf2aa6e1127a082423)`);
56
- }
57
- let filteredRespecPaths = undefined;
58
- if (LOOK_FOR_EXTRA_RESPEC) {
59
- const hasExtraRespecPromises = allRespecPaths.map(async (respecPath) => {
60
- const hasExtra = await respecFileHasExtraRespec(respecPath);
61
- return [respecPath, hasExtra];
62
- });
63
- const resPathHasExtraTuples = await Promise.all(hasExtraRespecPromises);
64
- filteredRespecPaths = resPathHasExtraTuples
65
- .filter(([_respecPath, hasExtra]) => hasExtra)
66
- .map(([respecPath, _hasExtra]) => respecPath);
67
- // if there are no files that have extra respec then we do all files
68
- if (filteredRespecPaths.length === 0) {
69
- if (logalot) {
70
- console.log(`filteredRespecPaths is empty. doing allRespecPaths found (I: b98f54656899646025eecb4c028ab523)`);
71
- }
72
- filteredRespecPaths = allRespecPaths.concat();
73
- }
74
- else {
75
- console.log(`filteredRespecPaths for extra respec: ${filteredRespecPaths} (I: b98f54656899646025eecb4c028ab523)`);
76
- respecGib.extraRespecOnly = true;
77
- }
78
- }
79
- // #endregion 1. get respec paths
80
- respecGib.allRespecPaths = allRespecPaths;
81
- respecGib.filteredRespecPaths = filteredRespecPaths;
82
- const respecPaths = filteredRespecPaths ?? allRespecPaths;
83
- respecGib.respecPaths = respecPaths;
84
- if (logalot) {
85
- console.log(`respecPaths found:\n${respecPaths}`);
86
- }
87
- // #region 2. execute paths' respective respecs
88
- // for now, we'll do sequentially, but in the future we could conceivable farm
89
- // these out to other node processes, or at least Promise.all
90
- for (let i = 0; i < respecPaths.length; i++) {
91
- const respecPath = respecPaths[i];
92
- if (logalot) {
93
- console.log(respecPath);
94
- }
95
- const respecPathUrl = pathToFileURL(respecPath).href;
96
- const esm = await import(respecPathUrl);
97
- if (logalot) {
98
- console.log(pretty(Object.keys(esm)));
99
- }
100
- }
101
- const skippedRespecPathCount = respecGib.allRespecPaths.length - respecGib.respecPaths.length;
102
- if (skippedRespecPathCount > 0) {
103
- console.log('');
104
- console.error('\x1b[33m%s\x1b[0m', `${skippedRespecPathCount} respec files completely skipped.`); // yellow
105
- }
106
- if (respecGib.ifWeBlocksSkipped > 0) {
107
- console.log('');
108
- console.error('\x1b[33m%s\x1b[0m', `${respecGib.ifWeBlocksSkipped} ifWe blocks ran but skipped reporting`); // yellow
109
- }
110
- if (respecGib.errorMsgs.length === 0) {
111
- console.log('');
112
- console.error('\x1b[32m%s\x1b[0m', `💚💚 nothing but respec 💚💚`); // green
113
- }
114
- else {
115
- console.log('');
116
- console.error('\x1b[31m%s\x1b[0m', `💔💔 DISrespec found 💔💔`); // red
117
- for (const errorMsg of respecGib.errorMsgs) {
118
- console.error('\x1b[31m%s\x1b[0m', errorMsg); // red
119
- }
120
- }
121
- // #endregion 2. execute paths' respective respecs
122
- // #region helper functions
123
- /**
124
- * builds a list of respec file paths, recursively traversing subdirectories
125
- * starting from `dirPath`.
126
- *
127
- * @param dirPath a full path corresponding to a directory
128
- * @param found respec paths already found (used in recursive calls)
129
- * @returns list of all respec paths according to the respec regexp constant {@link RESPEC_FILE_REG_EXP}
130
- */
131
- async function getRespecFileFullPaths(dirPath, found) {
132
- const lc = `[${getRespecFileFullPaths.name}][${dirPath}]`;
133
- try {
134
- if (logalot) {
135
- console.log(`${lc} starting... (I: 16026290523925f79ba1933847e2a623)`);
136
- }
137
- found ??= [];
138
- const children = await readdir(dirPath);
139
- if (logalot) {
140
- for (let i = 0; i < children.length; i++) {
141
- console.log(children[i]);
142
- }
143
- }
144
- const files = [];
145
- const dirs = [];
146
- children.forEach(name => {
147
- const fullPath = pathUtils.join(dirPath, name);
148
- const stat = statSync(fullPath);
149
- if (stat.isDirectory()) {
150
- // symbolic link could create a loop
151
- if (!stat.isSymbolicLink()) {
152
- dirs.push(fullPath);
153
- }
154
- }
155
- else if (!!name.match(RESPEC_FILE_REG_EXP)) {
156
- files.push(fullPath);
157
- }
158
- });
159
- found = found.concat(files);
160
- for (let i = 0; i < dirs.length; i++) {
161
- const subfound = await getRespecFileFullPaths(dirs[i], found);
162
- found = found.concat(subfound);
163
- }
164
- return Array.from(new Set(found)); // unique
165
- }
166
- catch (error) {
167
- console.error(`${lc} ${error.message}`);
168
- throw error;
169
- }
170
- finally {
171
- if (logalot) {
172
- console.log(`${lc} complete.`);
173
- }
174
- }
175
- }
176
- /**
177
- * Searches through the file (without importing it) for extra respecful
178
- * functions.
179
- *
180
- * @param respecPath
181
- * @returns true if extra respecful functions found in file
182
- */
183
- async function respecFileHasExtraRespec(respecPath) {
184
- const lc = `[${respecFileHasExtraRespec.name}]`;
185
- try {
186
- if (logalot) {
187
- console.log(`${lc} starting... (I: 61f3221917ba77175efa305b14defc23)`);
188
- }
189
- const file = await open(respecPath);
190
- for await (const line of file.readLines()) {
191
- const hasExtraRespecInLine = EXTRA_RESPEC_FUNCTION_NAMES.some(fnName => {
192
- if (line.includes(`${fnName}(`)) {
193
- return true;
194
- }
195
- });
196
- if (hasExtraRespecInLine) {
197
- return true;
198
- }
199
- }
200
- return false;
201
- }
202
- catch (error) {
203
- console.error(`${lc} ${error.message}`);
204
- throw error;
205
- }
206
- finally {
207
- if (logalot) {
208
- console.log(`${lc} complete.`);
209
- }
210
- }
211
- }
212
- // #endregion helper functions
1
+ import { RespecNodeRunner } from '@ibgib/helper-gib/dist/respec-gib/respec-node-runner.mjs';
2
+ const runner = new RespecNodeRunner();
3
+ await runner.run();
213
4
  //# sourceMappingURL=respec-gib.node.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"respec-gib.node.mjs","sourceRoot":"","sources":["../src/respec-gib.node.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,SAAS,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,iDAAiD,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AAEtF,mBAAmB;AACnB;;GAEG;AACH,MAAM,OAAO,GAAG,KAAK,CAAC;AAEtB,qDAAqD;AACrD,MAAM,gCAAgC,GAAG,QAAQ,CAAC;AAElD,iDAAiD;AACjD,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAC9C,4DAA4D;AAC5D,sDAAsD;AAEtD;;;;;;;;;GASG;AACH,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC;;;;;;;;GAQG;AACH,MAAM,2BAA2B,GAAa,CAAC,uBAAuB,EAAE,WAAW,CAAC,CAAC;AAErF,sBAAsB;AAEtB,8BAA8B;AAE9B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAC/B,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,gCAAgC,CAAC,CAAC;AAE3E,IAAI,OAAO,EAAE,CAAC;IAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAAC,CAAC;AACtD,IAAI,OA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QAAC,CAAC;IACpD,CAAC;AACL,CAAC;AAED,8BAA8B"}
1
+ {"version":3,"file":"respec-gib.node.mjs","sourceRoot":"","sources":["../src/respec-gib.node.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0DAA0D,CAAC;AAE5F,MAAM,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;AACtC,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibgib/web-gib",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "description": "Framework for creating agentic ibGib web apps. Contains plumbing for ibgib components, agentic framework (currently only Gemini implemented), web-based IndexedDB storage substrate, and more.",
5
5
  "funding": {
6
6
  "type": "individual",
@@ -11,7 +11,7 @@
11
11
  "web-gib-init-agents": "./tools/init-agents.js"
12
12
  },
13
13
  "scripts": {
14
- "clean": "node node_modules/@ibgib/helper-gib/tools/clean.js ./dist",
14
+ "clean": "node ../../node_modules/@ibgib/helper-gib/tools/clean.js ./dist",
15
15
  "generate:src:version": "node ./tools/generate-version-file.js",
16
16
  "generate:agent:skills": "node ./tools/copy-agent-skills.js",
17
17
  "prebuild": "npm run generate:src:version && npm run generate:agent:skills",
@@ -48,15 +48,12 @@
48
48
  "author": "William Raiford",
49
49
  "license": "ISC",
50
50
  "dependencies": {
51
- "@google/genai": "^1.33.0",
52
- "@ibgib/core-gib": "^0.1.51",
53
- "@ibgib/encrypt-gib": "^0.2.34",
54
- "@ibgib/helper-gib": "^0.0.33",
55
- "@ibgib/ts-gib": "^0.5.29"
56
- },
57
- "devDependencies": {
58
- "@types/node": "^20.2.1"
51
+ "@ibgib/core-gib": "^0.1.53",
52
+ "@ibgib/encrypt-gib": "^0.2.36",
53
+ "@ibgib/helper-gib": "^0.0.35",
54
+ "@ibgib/ts-gib": "^0.5.31"
59
55
  },
56
+ "devDependencies": {},
60
57
  "engines": {
61
58
  "node": ">=19.0.0"
62
59
  },
@@ -11,4 +11,4 @@
11
11
  /**
12
12
  * this is the version of this package, auto-updated in the build process
13
13
  */
14
- export const AUTO_GENERATED_VERSION = '0.0.32';
14
+ export const AUTO_GENERATED_VERSION = '0.0.34';
@@ -1,201 +1,4 @@
1
- import { readdir, open } from 'node:fs/promises';
2
- import { pathToFileURL } from 'node:url';
3
- import { statSync } from 'node:fs';
4
- import * as pathUtils from 'path';
1
+ import { RespecNodeRunner } from '@ibgib/helper-gib/dist/respec-gib/respec-node-runner.mjs';
5
2
 
6
- import { pretty } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
7
- import { getGlobalRespecGib } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
8
-
9
- // #region settings
10
- /**
11
- * This is how I enable/disable verbose logging. Do with it what you will.
12
- */
13
- const logalot = false;
14
-
15
- /** set this to the root of the respecs to look at */
16
- const RESPEC_ROOT_DIR_RELATIVE_TO_BASE = './dist';
17
-
18
- /** change this to suit your naming convention */
19
- const RESPEC_FILE_REG_EXP = /^.+respec\.mjs$/;
20
- // const RESPEC_FILE_REG_EXP = /^.*respec-gib.respec\.mjs$/;
21
- // if (respecPath.includes('respec-gib.respec.mjs')) {
22
-
23
- /**
24
- * If on, will first load a file and see if there is an extra respecful
25
- * `await respecfully`/`ifWe` block. Use these if you want to focus on a single or
26
- * subset of respecs.
27
- *
28
- * If there are no extra respecful blocks found in an entire file, that file
29
- * will be skipped.
30
- *
31
- * Note: this only is a flag to search through respec files.
32
- */
33
- const LOOK_FOR_EXTRA_RESPEC = true;
34
- /**
35
- * The names of the functions that indicate that we want to focus on just those
36
- * blocks.
37
- *
38
- * ATOW, for first run implementation here, I am implementing it such that it
39
- * will filter out files that don't have these indicators. The respec files that
40
- * do have these will execute fully, but the output will only include these
41
- * particular blocks.
42
- */
43
- const EXTRA_RESPEC_FUNCTION_NAMES: string[] = ['await respecfullyDear', 'ifWeMight'];
44
-
45
- // #endregion settings
46
-
47
- // #region 1. get respec paths
48
-
49
- const basePath = process.cwd();
50
- const srcPath = pathUtils.join(basePath, RESPEC_ROOT_DIR_RELATIVE_TO_BASE);
51
-
52
- if (logalot) { console.log(`cwd: ${process.cwd()}`); }
53
- if (logalot) { console.log(`basePath: ${basePath}`); }
54
- if (logalot) { console.log(`srcPath: ${srcPath}`); }
55
-
56
-
57
- const respecGib = getGlobalRespecGib();
58
- const allRespecPaths = await getRespecFileFullPaths(srcPath, []);
59
-
60
- if (logalot) { console.log(`allRespecPaths: ${allRespecPaths} (I: f5182a455375a8cf2aa6e1127a082423)`); }
61
- let filteredRespecPaths: string[] | undefined = undefined;
62
-
63
- if (LOOK_FOR_EXTRA_RESPEC) {
64
- const hasExtraRespecPromises = allRespecPaths.map(async respecPath => {
65
- const hasExtra = await respecFileHasExtraRespec(respecPath);
66
- return [respecPath, hasExtra] as [string, boolean];
67
- });
68
- const resPathHasExtraTuples = await Promise.all(hasExtraRespecPromises);
69
- filteredRespecPaths = resPathHasExtraTuples
70
- .filter(([_respecPath, hasExtra]) => hasExtra)
71
- .map(([respecPath, _hasExtra]) => respecPath);
72
-
73
- // if there are no files that have extra respec then we do all files
74
- if (filteredRespecPaths.length === 0) {
75
- if (logalot) { console.log(`filteredRespecPaths is empty. doing allRespecPaths found (I: b98f54656899646025eecb4c028ab523)`); }
76
- filteredRespecPaths = allRespecPaths.concat();
77
- } else {
78
- console.log(`filteredRespecPaths for extra respec: ${filteredRespecPaths} (I: b98f54656899646025eecb4c028ab523)`);
79
- respecGib.extraRespecOnly = true;
80
- }
81
- }
82
-
83
- // #endregion 1. get respec paths
84
-
85
- respecGib.allRespecPaths = allRespecPaths;
86
- respecGib.filteredRespecPaths = filteredRespecPaths;
87
- const respecPaths = filteredRespecPaths ?? allRespecPaths;
88
- respecGib.respecPaths = respecPaths;
89
- if (logalot) { console.log(`respecPaths found:\n${respecPaths}`); }
90
-
91
- // #region 2. execute paths' respective respecs
92
-
93
- // for now, we'll do sequentially, but in the future we could conceivable farm
94
- // these out to other node processes, or at least Promise.all
95
-
96
- for (let i = 0; i < respecPaths.length; i++) {
97
- const respecPath = respecPaths[i];
98
- if (logalot) { console.log(respecPath); }
99
- const respecPathUrl = pathToFileURL(respecPath).href;
100
- const esm = await import(respecPathUrl);
101
- if (logalot) { console.log(pretty(Object.keys(esm))); }
102
- }
103
-
104
- const skippedRespecPathCount = respecGib.allRespecPaths.length - respecGib.respecPaths.length;
105
- if (skippedRespecPathCount > 0) {
106
- console.log('');
107
- console.error('\x1b[33m%s\x1b[0m', `${skippedRespecPathCount} respec files completely skipped.`); // yellow
108
- }
109
- if (respecGib.ifWeBlocksSkipped > 0) {
110
- console.log('');
111
- console.error('\x1b[33m%s\x1b[0m', `${respecGib.ifWeBlocksSkipped} ifWe blocks ran but skipped reporting`); // yellow
112
- }
113
-
114
- if (respecGib.errorMsgs.length === 0) {
115
- console.log('');
116
- console.error('\x1b[32m%s\x1b[0m', `💚💚 nothing but respec 💚💚`); // green
117
- } else {
118
- console.log('');
119
- console.error('\x1b[31m%s\x1b[0m', `💔💔 DISrespec found 💔💔`); // red
120
- for (const errorMsg of respecGib.errorMsgs) {
121
- console.error('\x1b[31m%s\x1b[0m', errorMsg); // red
122
- }
123
- }
124
-
125
- // #endregion 2. execute paths' respective respecs
126
-
127
- // #region helper functions
128
-
129
- /**
130
- * builds a list of respec file paths, recursively traversing subdirectories
131
- * starting from `dirPath`.
132
- *
133
- * @param dirPath a full path corresponding to a directory
134
- * @param found respec paths already found (used in recursive calls)
135
- * @returns list of all respec paths according to the respec regexp constant {@link RESPEC_FILE_REG_EXP}
136
- */
137
- async function getRespecFileFullPaths(dirPath: string, found: string[]): Promise<string[]> {
138
- const lc = `[${getRespecFileFullPaths.name}][${dirPath}]`;
139
- try {
140
- if (logalot) { console.log(`${lc} starting... (I: 16026290523925f79ba1933847e2a623)`); }
141
- found ??= [];
142
- const children = await readdir(dirPath);
143
- if (logalot) { for (let i = 0; i < children.length; i++) { console.log(children[i]); } }
144
- const files: string[] = [];
145
- const dirs: string[] = [];
146
- children.forEach(name => {
147
- const fullPath = pathUtils.join(dirPath, name);
148
- const stat = statSync(fullPath);
149
- if (stat.isDirectory()) {
150
- // symbolic link could create a loop
151
- if (!stat.isSymbolicLink()) { dirs.push(fullPath); }
152
- } else if (!!name.match(RESPEC_FILE_REG_EXP)) {
153
- files.push(fullPath);
154
- }
155
- });
156
-
157
- found = found.concat(files);
158
- for (let i = 0; i < dirs.length; i++) {
159
- const subfound = await getRespecFileFullPaths(dirs[i], found);
160
- found = found.concat(subfound);
161
- }
162
- return Array.from(new Set(found)); // unique
163
- } catch (error) {
164
- console.error(`${lc} ${error.message}`);
165
- throw error;
166
- } finally {
167
- if (logalot) { console.log(`${lc} complete.`); }
168
- }
169
- }
170
-
171
- /**
172
- * Searches through the file (without importing it) for extra respecful
173
- * functions.
174
- *
175
- * @param respecPath
176
- * @returns true if extra respecful functions found in file
177
- */
178
- async function respecFileHasExtraRespec(respecPath: string): Promise<boolean> {
179
- const lc = `[${respecFileHasExtraRespec.name}]`;
180
- try {
181
- if (logalot) { console.log(`${lc} starting... (I: 61f3221917ba77175efa305b14defc23)`); }
182
- const file = await open(respecPath);
183
- for await (const line of file.readLines()) {
184
- const hasExtraRespecInLine =
185
- EXTRA_RESPEC_FUNCTION_NAMES.some(fnName => {
186
- if (line.includes(`${fnName}(`)) { return true; }
187
- });
188
- if (hasExtraRespecInLine) {
189
- return true;
190
- }
191
- }
192
- return false;
193
- } catch (error) {
194
- console.error(`${lc} ${error.message}`);
195
- throw error;
196
- } finally {
197
- if (logalot) { console.log(`${lc} complete.`); }
198
- }
199
- }
200
-
201
- // #endregion helper functions
3
+ const runner = new RespecNodeRunner();
4
+ await runner.run();
@@ -4,10 +4,15 @@ import { writeFile } from 'node:fs/promises';
4
4
 
5
5
  import packageJson from '../package.json' with {type: 'json'};
6
6
 
7
+ import { fileURLToPath } from 'node:url';
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = pathUtils.dirname(__filename);
11
+
7
12
  const lc = `[${import.meta.url}]`;
8
13
  console.log(`${lc} starting... (I: 1cb5f4175a1e2ccff8045ec622ed6825)`)
9
14
 
10
- const filePath = pathUtils.resolve('./src/AUTO-GENERATED-version.mts')
15
+ const filePath = pathUtils.resolve(__dirname, '../src/AUTO-GENERATED-version.mts')
11
16
 
12
17
  const contents = `/**
13
18
  * @module auto-generated-version
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
@@ -5,6 +5,6 @@
5
5
  "module": "ESNext", /* https://www.typescriptlang.org/docs/handbook/esm-node.html */
6
6
  },
7
7
  "exclude": [
8
- // override inherited exclude of spec files
8
+ "./dist"
9
9
  ]
10
10
  }