vbapm 0.6.15 → 0.8.0

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 (71) hide show
  1. package/README.md +86 -0
  2. package/addins/build/vbapm.xlam +0 -0
  3. package/lib/actions/add-source.d.ts +11 -0
  4. package/lib/actions/export-project.d.ts +2 -0
  5. package/lib/actions/update-project.d.ts +7 -0
  6. package/lib/add-source-BOumGmx7.js +17 -0
  7. package/lib/addin.d.ts +1 -0
  8. package/lib/bin/vbapm-add.d.ts +2 -0
  9. package/lib/bin/vbapm-update.d.ts +2 -0
  10. package/lib/build-project-De7NPBpt.js +3 -0
  11. package/lib/build-target-ooHNsSLD.js +9 -0
  12. package/lib/{create-project-CPIRr0DV.js → create-project-BYc3XMZw.js} +1 -1
  13. package/lib/debug.js +1 -1
  14. package/lib/errors.d.ts +6 -0
  15. package/lib/export-project-CgFMyE-g.js +4 -0
  16. package/lib/export-target-C0RYJqUX.js +4 -0
  17. package/lib/{get-target-CH6IpAa1.js → get-target-LUoY1UWJ.js} +1 -1
  18. package/lib/index-C61lSPb5.js +1 -0
  19. package/lib/index-CBGUBgfk.js +13 -0
  20. package/lib/index-ClUEyMCY.js +6 -0
  21. package/lib/{index-Dg07BXJE.js → index-Cp8MNK26.js} +1 -1
  22. package/lib/{index-D-khpcjL.js → index-Dv6JxqGo.js} +9 -9
  23. package/lib/index.d.ts +1 -0
  24. package/lib/index.js +1 -1
  25. package/lib/init-project-9RKSVG_H.js +15 -0
  26. package/lib/installer-DPj-zT7L.js +9 -0
  27. package/lib/{load-from-project-Bpb6Ne_i.js → load-from-project-ClF4qaC0.js} +1 -1
  28. package/lib/messages.d.ts +2 -0
  29. package/lib/one_ini_bg.wasm +0 -0
  30. package/lib/project-BPmPCkUS.js +20 -0
  31. package/lib/run-macro-C1-aJWu5.js +1 -0
  32. package/lib/sat-solver-B6RXdyQs.js +1 -0
  33. package/lib/targets/build-target.d.ts +1 -0
  34. package/lib/targets/export-target.d.ts +3 -1
  35. package/lib/targets/transforms/format-xml.d.ts +2 -0
  36. package/lib/test-project-DXBFZH3o.js +1 -0
  37. package/lib/toml-patch-r8oqFm0h.js +3 -0
  38. package/lib/transform-build-graph-DgRrocSn.js +1 -0
  39. package/lib/transform-target-CYhuozxP.js +2 -0
  40. package/lib/utils/encoding.d.ts +30 -0
  41. package/lib/utils/run.d.ts +4 -1
  42. package/lib/utils/xml.d.ts +14 -0
  43. package/lib/vbapm-add-CASFjXAL.js +16 -0
  44. package/lib/vbapm-build-Bhm_pqQW.js +9 -0
  45. package/lib/vbapm-export-8KDCdFOz.js +9 -0
  46. package/lib/{vbapm-init-csKsZ87H.js → vbapm-init-Ba2xCez2.js} +1 -1
  47. package/lib/{vbapm-new-Dt0tX1xQ.js → vbapm-new-YQRNQ4Iq.js} +1 -1
  48. package/lib/{vbapm-run-Ccciwg2y.js → vbapm-run-J-R--noZ.js} +2 -2
  49. package/lib/{vbapm-test-u7AWC-AV.js → vbapm-test-C4KWMPLz.js} +1 -1
  50. package/lib/vbapm-update-DnbmW8tc.js +13 -0
  51. package/lib/vbapm-version-CRicT8YA.js +8 -0
  52. package/lib/vbapm.js +3 -1
  53. package/package.json +127 -137
  54. package/run-scripts/run.applescript +18 -7
  55. package/run-scripts/run.ps1 +42 -10
  56. package/lib/build-project-BczswKQl.js +0 -3
  57. package/lib/build-target-D6L5nsgt.js +0 -9
  58. package/lib/export-project-DQ3bfvbV.js +0 -4
  59. package/lib/export-target-CN6RA_mA.js +0 -4
  60. package/lib/index-DXFu_Z-o.js +0 -6
  61. package/lib/init-project-dRuDA4YO.js +0 -15
  62. package/lib/installer-CJlDenLg.js +0 -9
  63. package/lib/project-C3bWzV0O.js +0 -29
  64. package/lib/run-macro-D_9-BO3U.js +0 -1
  65. package/lib/sat-solver-5AniWyxz.js +0 -1
  66. package/lib/test-project-BTkTNZXs.js +0 -1
  67. package/lib/toml-patch.es-CxrbsPnB.js +0 -3
  68. package/lib/transform-target-Doak2S1q.js +0 -2
  69. package/lib/vbapm-build-B1OOy6VL.js +0 -9
  70. package/lib/vbapm-export-vvUDCDqi.js +0 -7
  71. package/lib/vbapm-version-Bsb-cWCD.js +0 -8
package/README.md CHANGED
@@ -122,6 +122,40 @@ Create a blank package:
122
122
  vba init --package
123
123
  ```
124
124
 
125
+ ### `add`
126
+
127
+ Create a new source file in `src/` and register it in `vbaproject.toml`.
128
+
129
+ Create a standard module:
130
+
131
+ ```txt
132
+ vba add Module1
133
+ ```
134
+
135
+ Create a class module:
136
+
137
+ ```txt
138
+ vba add JsonParser --type class
139
+ ```
140
+
141
+ Register an existing source file by path (no overwrite):
142
+
143
+ ```txt
144
+ vba add .\src\Test.bas
145
+ ```
146
+
147
+ Create and register a file in a nested path (missing folders are created):
148
+
149
+ ```txt
150
+ vba add .\src\features\auth\LoginHelper.bas
151
+ ```
152
+
153
+ Add a development-only source to `[dev-src]`:
154
+
155
+ ```txt
156
+ vba add TestHelpers --dev
157
+ ```
158
+
125
159
  ### `build`
126
160
 
127
161
  Build an Excel workbook from the project's source. The built file is located in the `build/` folder and if a previously built file is found it is moved to `/.backup` to protect against losing any previously saved work.
@@ -166,6 +200,46 @@ Export a previously-built package:
166
200
  vba export --target xlsm
167
201
  ```
168
202
 
203
+ Only extract the XML files (skip VBA source export):
204
+
205
+ ```txt
206
+ vba export --xml-only
207
+ ```
208
+
209
+ Only export the VBA source (skip XML extraction):
210
+
211
+ ```txt
212
+ vba export --vba-only
213
+ ```
214
+
215
+ ### `update`
216
+
217
+ `vba update` writes the current VBA source directly into an existing built target file (including one currently open in Excel), without going through a full build cycle.
218
+
219
+ Update VBA source in the built target:
220
+
221
+ ```txt
222
+ vba update
223
+ ```
224
+
225
+ Update VBA in a specific target type:
226
+
227
+ ```txt
228
+ vba update --target xlsm
229
+ ```
230
+
231
+ Update excluding dev-src, dev-dependencies, and dev-references:
232
+
233
+ ```txt
234
+ vba update --release
235
+ ```
236
+
237
+ Update and leave the target open in Excel after updating:
238
+
239
+ ```txt
240
+ vba update --open
241
+ ```
242
+
169
243
  ### `run`
170
244
 
171
245
  `vba run` is a useful utility function for running a public macro in the given workbook, passing up to 10 arguments, and if it returns a string value, outputing it to the console.
@@ -305,6 +379,18 @@ Scripting = { version = "1.0", guid = "{...}" }
305
379
  <br>It will run the end-to-end CLI scenarios in excel.e2e.ts, covering workflows like build, export, new, and version against fixtures.
306
380
  <br>To keep temporary e2e work folders for manual inspection, set `KEEP_E2E_TMP=1` before running (PowerShell: `$env:KEEP_E2E_TMP=1; npm run test:e2e`, cmd: `set KEEP_E2E_TMP=1 && npm run test:e2e`).
307
381
 
382
+ ### Install local version
383
+
384
+ To install the local version you can use the `devinstall.ps1` script available in the installer submodule.
385
+
386
+ ```powershell
387
+ # Update submodule
388
+ git submodule update --init --recursive installer
389
+
390
+ # Run devinstall
391
+ .\installer\devinstall.ps1
392
+ ```
393
+
308
394
  ### Release
309
395
 
310
396
  1. Run `npm version`
Binary file
@@ -0,0 +1,11 @@
1
+ export interface AddSourceOptions {
2
+ name?: string;
3
+ type?: string;
4
+ dir?: string;
5
+ dev: boolean;
6
+ }
7
+ export interface AddSourceResult {
8
+ path: string;
9
+ isNew: boolean;
10
+ }
11
+ export declare function addSource(options: AddSourceOptions): Promise<AddSourceResult>;
@@ -2,5 +2,7 @@ export interface ExportOptions {
2
2
  target?: string;
3
3
  completed?: string;
4
4
  addin?: string;
5
+ xmlOnly?: boolean;
6
+ vbaOnly?: boolean;
5
7
  }
6
8
  export declare function exportProject(options?: ExportOptions): Promise<void>;
@@ -0,0 +1,7 @@
1
+ export interface UpdateOptions {
2
+ target?: string;
3
+ addin?: string;
4
+ release?: boolean;
5
+ open?: boolean;
6
+ }
7
+ export declare function updateProject(options?: UpdateOptions): Promise<string>;
@@ -0,0 +1,17 @@
1
+ "use strict";var e=require("./installer-DPj-zT7L.js"),r=require("./index-CBGUBgfk.js"),t=require("path");const n={".bas":"module",".cls":"class"},a={module:".bas",class:".cls"},o=/^[\p{L}_][\p{L}\p{N}\p{M}_]*$/u;exports.addSource=async function(s){const{name:d,type:i,dir:c,dev:u}=s,l=c||e.env.cwd;if(!d)throw new e.CliError(e.ErrorCode.AddNameRequired,e.dedent`
2
+ "name" is required with vbapm add (e.g. vbapm add Module1).
3
+
4
+ Try "vbapm help add" for more information.
5
+ `);const p=await r.loadManifest(l),m=function(r,o){const s=t.extname(r).toLowerCase(),d=o&&a[o.toLowerCase()];if(s&&!(s in n))throw new e.CliError(e.ErrorCode.AddUnsupportedType,`Unsupported source extension "${s}". Supported extensions are .bas and .cls.`);if(o&&!d)throw new e.CliError(e.ErrorCode.AddUnsupportedType,`Unsupported --type "${o}". Supported types are "module" and "class".`);if(s&&d&&s!==d)throw new e.CliError(e.ErrorCode.AddUnsupportedType,`Type "${o}" conflicts with extension "${s}".`);return s||(d||".bas")}(d,i);let w=d.includes("/")||d.includes("\\")?e.join(l,d):e.join(l,"src",d);t.extname(w)||(w=`${w}${m}`);const E=t.basename(w,t.extname(w));if(!E)throw new e.CliError(e.ErrorCode.AddInvalidName,`Invalid source name "${d}".`);if(!o.test(E))throw new e.CliError(e.ErrorCode.AddInvalidName,`Invalid VBA component name "${E}". Use Unicode letters, numbers, and underscores only, and do not start with a number.`);const b=u?"dev-src":"src",h=p.src.find(e=>e.name===E||e.path===w),f=p.devSrc.find(e=>e.name===E||e.path===w);if(h||f){const r=h?"src":"dev-src";throw new e.CliError(e.ErrorCode.AddSourceExists,`Source "${E}" already exists in [${r}] and cannot be added to [${b}].`)}const C=u?p.devSrc:p.src,x=await e.pathExistsExports.pathExists(w);x||(await e.mkdirsExports.ensureDir(t.dirname(w)),await e.writeFile(w,function(r,t){if(".cls"===t)return e.dedent`
6
+ VERSION 1.0 CLASS
7
+ BEGIN
8
+ MultiUse = -1 'True
9
+ END
10
+ Attribute VB_Name = "${r}"
11
+ Attribute VB_GlobalNameSpace = False
12
+ Attribute VB_Creatable = False
13
+ Attribute VB_PredeclaredId = False
14
+ Attribute VB_Exposed = False
15
+ `+"\n\n";return e.dedent`
16
+ Attribute VB_Name = "${r}"
17
+ `+"\n\n"}(E,m)));const A={name:E,path:w};return C.push(A),await r.writeManifest(p,l),{path:w,isNew:!x}};
package/lib/addin.d.ts CHANGED
@@ -5,6 +5,7 @@ export type Application = "excel";
5
5
  export type Addin = string;
6
6
  export interface AddinOptions {
7
7
  addin?: string;
8
+ open?: boolean;
8
9
  staging?: boolean;
9
10
  }
10
11
  export declare const extensions: {
@@ -0,0 +1,2 @@
1
+ import { Args } from "mri";
2
+ export default function (args: Args): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { Args } from "mri";
2
+ export default function (args: Args): Promise<void>;
@@ -0,0 +1,3 @@
1
+ "use strict";var e=require("./installer-DPj-zT7L.js"),r=require("./project-BPmPCkUS.js"),t=require("./index-CBGUBgfk.js"),i=require("./build-target-ooHNsSLD.js");require("assert"),require("./transform-build-graph-DgRrocSn.js"),require("fs"),require("./transform-target-CYhuozxP.js");var n=require("./get-target-LUoY1UWJ.js");exports.buildProject=async function(a={}){e.env.reporter.log(e.Message.BuildProjectLoading,"[1/3] Loading project...");const s=await r.loadProject(),{target:o,blankTarget:g}=n.getTarget(s,a.target),c=await r.fetchDependencies(s),d=s.packages.map(e=>{const i=r.toDependency(e);return t.isRegistryDependency(i)?`${e.id} registry+${i.registry}`:`${e.id} ${e.source}`});e.env.reporter.log(e.Message.BuildTargetBuilding,e.dedent`
2
+ \n[2/3] Building target "${o.type}" for "${s.manifest.name}"...
3
+ ${d.length?`\nDependencies:\n${d.join("\n")}`:""}`),await i.buildTarget(o,{project:s,dependencies:c,blankTarget:g},a);const l=!s.hasDirtyLockfile;return e.env.reporter.log(e.Message.BuildLockfileWriting,"\n[3/3] Writing lockfile..."+(l?" (skipped, no changes)":"")),l||await r.writeLockfile(s.paths.root,s),e.join(s.paths.dir,"build",o.filename)};
@@ -0,0 +1,9 @@
1
+ "use strict";var t=require("./installer-DPj-zT7L.js"),r=require("./transform-build-graph-DgRrocSn.js");require("assert");var a=require("./load-from-project-ClF4qaC0.js"),e=require("path"),i=require("./project-BPmPCkUS.js");const o=t=>/1004/.test(t),n=(r,a)=>t.dedent`
2
+ Failed to build target "${r.name}", it is currently open.
3
+
4
+ Please close "${a}" and try again.
5
+ `;async function s(r,a){if(!await t.pathExistsExports.pathExists(a.path))throw new t.CliError(t.ErrorCode.TargetNotFound,`Target "${a.name}" not found at "${a.path}".`);const e=t.join(r.paths.staging,a.filename);try{await t.mkdirsExports.ensureDir(r.paths.staging),await i.zip(a.path,e)}catch(r){throw new t.CliError(t.ErrorCode.TargetCreateFailed,`Failed to create project for target "${a.name}".`,r)}return e}async function p(i,o,n,s={}){const{project:p,dependencies:c}=o,l=t.join(p.paths.staging,"import");await t.mkdirsExports.ensureDir(l),await t.emptyExports.emptyDir(l);const m=await a.loadFromProject(p,c,s),w=await async function(r,a){const i=await t.parallel(r.components,async r=>{const i=t.join(a,r.filename);if(await t.writeFile(i,r.code),r.binaryPath){const i=t.join(a,e.basename(r.binaryPath));if(!r.details.binary)throw new Error(`Binary data missing for component "${r.name}"`);await t.writeFile(i,r.details.binary)}return{name:r.name,path:i}});return{name:r.name,components:i,references:r.references}}(m,l);try{await r.importGraph(p,i,w,n,s)}catch(r){throw new t.CliError(t.ErrorCode.TargetImportFailed,`Failed to import project for target "${i.name}".`,r)}finally{await t.removeExports.remove(l)}}exports.buildTarget=async function(a,e,i={}){const{project:c}=e;let l;try{l=e.blankTarget?await r.createDocument(c,a,{staging:!0}):await s(c,a)}catch(r){if(!t.isRunError(r)||!r.result.errors.some(o))throw r;const e=t.join(c.paths.build,a.filename);throw new t.CliError(t.ErrorCode.TargetIsOpen,n(a,e))}await p(a,e,l,i);try{await async function(r,a){const e=t.join(r.paths.backup,a.filename),i=t.join(r.paths.build,a.filename);await t.pathExistsExports.pathExists(e)&&await t.removeExports.remove(e);if(await t.pathExistsExports.pathExists(i)){await t.mkdirsExports.ensureDir(r.paths.backup);try{await t.moveExports.move(i,e)}catch(r){throw new t.CliError(t.ErrorCode.TargetIsOpen,n(a,i))}}}(c,a);const r=t.join(c.paths.build,a.filename);await t.moveExports.move(l,r)}catch(r){throw await async function(r,a){const e=t.join(r.paths.backup,a.filename),i=t.join(r.paths.build,a.filename);if(!await t.pathExistsExports.pathExists(e))return;try{await t.copyExports.copy(e,i)}catch(r){throw new t.CliError(t.ErrorCode.TargetRestoreFailed,t.dedent`
6
+ Failed to automatically restore backup from "${e}" to "${i}".
7
+
8
+ The previous version can be moved back manually, if desired.
9
+ `,r)}}(c,a),r}finally{await t.removeExports.remove(l)}},exports.importTarget=p;
@@ -1,4 +1,4 @@
1
- "use strict";var r=require("./installer-CJlDenLg.js"),e=require("./init-project-dRuDA4YO.js");exports.createProject=async function(t){if(!t||!t.name)throw new r.CliError(r.ErrorCode.NewNameRequired,r.dedent`
1
+ "use strict";var r=require("./installer-DPj-zT7L.js"),e=require("./init-project-9RKSVG_H.js");exports.createProject=async function(t){if(!t||!t.name)throw new r.CliError(r.ErrorCode.NewNameRequired,r.dedent`
2
2
  "name" is required with vbapm new (e.g. vbapm new project-name).
3
3
 
4
4
  Try "vbapm help new" for more information.
package/lib/debug.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,r,s=require("./_commonjsHelpers-Bjf42z7h.js"),t=require("tty"),n=require("util"),o=require("os"),c={exports:{}};var i,u,a,l,f,p,d,m,h,g,O={exports:{}};function y(){return u?i:(u=1,i=(e,r)=>{r=r||process.argv;const s=e.startsWith("-")?"":1===e.length?"-":"--",t=r.indexOf(s+e),n=r.indexOf("--");return-1!==t&&(-1===n||t<n)})}function b(){if(l)return a;l=1;const e=o,r=y(),s=process.env;let t;function n(n){const o=function(n){if(!1===t)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(n&&!n.isTTY&&!0!==t)return 0;const o=t?1:0;if("win32"===process.platform){const r=e.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in s)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in s)||"codeship"===s.CI_NAME?1:o;if("TEAMCITY_VERSION"in s)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(s.TEAMCITY_VERSION)?1:0;if("truecolor"===s.COLORTERM)return 3;if("TERM_PROGRAM"in s){const e=parseInt((s.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(s.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(s.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(s.TERM)||"COLORTERM"in s?1:(s.TERM,o)}(n);return function(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}(o)}return r("no-color")||r("no-colors")||r("color=false")?t=!1:(r("color")||r("colors")||r("color=true")||r("color=always"))&&(t=!0),"FORCE_COLOR"in s&&(t=0===s.FORCE_COLOR.length||0!==parseInt(s.FORCE_COLOR,10)),a={supportsColor:n,stdout:n(process.stdout),stderr:n(process.stderr)}}function v(){if(p)return f;p=1;var e=1e3,r=60*e,s=60*r,t=24*s,n=7*t,o=365.25*t;function c(e,r,s,t){var n=r>=1.5*s;return Math.round(e/s)+" "+t+(n?"s":"")}return f=function(i,u){u=u||{};var a=typeof i;if("string"===a&&i.length>0)return function(c){if((c=String(c)).length>100)return;var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(c);if(!i)return;var u=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return u*o;case"weeks":case"week":case"w":return u*n;case"days":case"day":case"d":return u*t;case"hours":case"hour":case"hrs":case"hr":case"h":return u*s;case"minutes":case"minute":case"mins":case"min":case"m":return u*r;case"seconds":case"second":case"secs":case"sec":case"s":return u*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return u;default:return}}(i);if("number"===a&&isFinite(i))return u.long?function(n){var o=Math.abs(n);if(o>=t)return c(n,o,t,"day");if(o>=s)return c(n,o,s,"hour");if(o>=r)return c(n,o,r,"minute");if(o>=e)return c(n,o,e,"second");return n+" ms"}(i):function(n){var o=Math.abs(n);if(o>=t)return Math.round(n/t)+"d";if(o>=s)return Math.round(n/s)+"h";if(o>=r)return Math.round(n/r)+"m";if(o>=e)return Math.round(n/e)+"s";return n+"ms"}(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))}}function C(){return h||(h=1,function(e,r){const s=t,o=n;r.init=function(e){e.inspectOpts={};const s=Object.keys(r.inspectOpts);for(let t=0;t<s.length;t++)e.inspectOpts[s[t]]=r.inspectOpts[s[t]]},r.log=function(...e){return process.stderr.write(o.formatWithOptions(r.inspectOpts,...e)+"\n")},r.formatArgs=function(s){const{namespace:t,useColors:n}=this;if(n){const r=this.color,n="[3"+(r<8?r:"8;5;"+r),o=` ${n};1m${t} `;s[0]=o+s[0].split("\n").join("\n"+o),s.push(n+"m+"+e.exports.humanize(this.diff)+"")}else s[0]=function(){if(r.inspectOpts.hideDate)return"";return(new Date).toISOString()+" "}()+t+" "+s[0]},r.save=function(e){e?process.env.DEBUG=e:delete process.env.DEBUG},r.load=function(){return process.env.DEBUG},r.useColors=function(){return"colors"in r.inspectOpts?Boolean(r.inspectOpts.colors):s.isatty(process.stderr.fd)},r.destroy=o.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),r.colors=[6,2,3,4,5,1];try{const e=b();e&&(e.stderr||e).level>=2&&(r.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}r.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,r)=>{const s=r.substring(6).toLowerCase().replace(/_([a-z])/g,(e,r)=>r.toUpperCase());let t=process.env[r];return t=!!/^(yes|on|true|enabled)$/i.test(t)||!/^(no|off|false|disabled)$/i.test(t)&&("null"===t?null:Number(t)),e[s]=t,e},{}),e.exports=(m||(m=1,d=function(e){function r(e){let t,n,o,c=null;function i(...e){if(!i.enabled)return;const s=i,n=Number(new Date),o=n-(t||n);s.diff=o,s.prev=t,s.curr=n,t=n,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let c=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,n)=>{if("%%"===t)return"%";c++;const o=r.formatters[n];if("function"==typeof o){const r=e[c];t=o.call(s,r),e.splice(c,1),c--}return t}),r.formatArgs.call(s,e),(s.log||r.log).apply(s,e)}return i.namespace=e,i.useColors=r.useColors(),i.color=r.selectColor(e),i.extend=s,i.destroy=r.destroy,Object.defineProperty(i,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==c?c:(n!==r.namespaces&&(n=r.namespaces,o=r.enabled(e)),o),set:e=>{c=e}}),"function"==typeof r.init&&r.init(i),i}function s(e,s){const t=r(this.namespace+(void 0===s?":":s)+e);return t.log=this.log,t}function t(e,r){let s=0,t=0,n=-1,o=0;for(;s<e.length;)if(t<r.length&&(r[t]===e[s]||"*"===r[t]))"*"===r[t]?(n=t,o=s,t++):(s++,t++);else{if(-1===n)return!1;t=n+1,o++,s=o}for(;t<r.length&&"*"===r[t];)t++;return t===r.length}return r.debug=r,r.default=r,r.coerce=function(e){return e instanceof Error?e.stack||e.message:e},r.disable=function(){const e=[...r.names,...r.skips.map(e=>"-"+e)].join(",");return r.enable(""),e},r.enable=function(e){r.save(e),r.namespaces=e,r.names=[],r.skips=[];const s=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of s)"-"===e[0]?r.skips.push(e.slice(1)):r.names.push(e)},r.enabled=function(e){for(const s of r.skips)if(t(e,s))return!1;for(const s of r.names)if(t(e,s))return!0;return!1},r.humanize=v(),r.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(s=>{r[s]=e[s]}),r.names=[],r.skips=[],r.formatters={},r.selectColor=function(e){let s=0;for(let r=0;r<e.length;r++)s=(s<<5)-s+e.charCodeAt(r),s|=0;return r.colors[Math.abs(s)%r.colors.length]},r.enable(r.load()),r}),d)(r);const{formatters:c}=e.exports;c.o=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts).split("\n").map(e=>e.trim()).join(" ")},c.O=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts)}}(O,O.exports)),O.exports}var R=(g||(g=1,"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?c.exports=r?e:(r=1,e={}):c.exports=C()),c.exports),E=s.getDefaultExportFromCjs(R);module.exports=E;
1
+ "use strict";var e,r,t=require("./_commonjsHelpers-Bjf42z7h.js"),s=require("tty"),n=require("util"),o=require("os"),i={exports:{}};var c,a,u,l,f,p,d,m,h,O,g={exports:{}};function y(){return a?c:(a=1,c=(e,r=process.argv)=>{const t=e.startsWith("-")?"":1===e.length?"-":"--",s=r.indexOf(t+e),n=r.indexOf("--");return-1!==s&&(-1===n||s<n)})}function b(){if(p)return f;p=1;var e=1e3,r=60*e,t=60*r,s=24*t,n=7*s,o=365.25*s;function i(e,r,t,s){var n=r>=1.5*t;return Math.round(e/t)+" "+s+(n?"s":"")}return f=function(c,a){a=a||{};var u=typeof c;if("string"===u&&c.length>0)return function(i){if((i=String(i)).length>100)return;var c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(!c)return;var a=parseFloat(c[1]);switch((c[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*o;case"weeks":case"week":case"w":return a*n;case"days":case"day":case"d":return a*s;case"hours":case"hour":case"hrs":case"hr":case"h":return a*t;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(c);if("number"===u&&isFinite(c))return a.long?function(n){var o=Math.abs(n);if(o>=s)return i(n,o,s,"day");if(o>=t)return i(n,o,t,"hour");if(o>=r)return i(n,o,r,"minute");if(o>=e)return i(n,o,e,"second");return n+" ms"}(c):function(n){var o=Math.abs(n);if(o>=s)return Math.round(n/s)+"d";if(o>=t)return Math.round(n/t)+"h";if(o>=r)return Math.round(n/r)+"m";if(o>=e)return Math.round(n/e)+"s";return n+"ms"}(c);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(c))}}function v(){return h||(h=1,function(e,r){const t=s,i=n;r.init=function(e){e.inspectOpts={};const t=Object.keys(r.inspectOpts);for(let s=0;s<t.length;s++)e.inspectOpts[t[s]]=r.inspectOpts[t[s]]},r.log=function(...e){return process.stderr.write(i.formatWithOptions(r.inspectOpts,...e)+"\n")},r.formatArgs=function(t){const{namespace:s,useColors:n}=this;if(n){const r=this.color,n="[3"+(r<8?r:"8;5;"+r),o=` ${n};1m${s} `;t[0]=o+t[0].split("\n").join("\n"+o),t.push(n+"m+"+e.exports.humanize(this.diff)+"")}else t[0]=function(){if(r.inspectOpts.hideDate)return"";return(new Date).toISOString()+" "}()+s+" "+t[0]},r.save=function(e){e?process.env.DEBUG=e:delete process.env.DEBUG},r.load=function(){return process.env.DEBUG},r.useColors=function(){return"colors"in r.inspectOpts?Boolean(r.inspectOpts.colors):t.isatty(process.stderr.fd)},r.destroy=i.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),r.colors=[6,2,3,4,5,1];try{const e=function(){if(l)return u;l=1;const e=o,r=s,t=y(),{env:n}=process;let i;function c(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function a(r,s){if(0===i)return 0;if(t("color=16m")||t("color=full")||t("color=truecolor"))return 3;if(t("color=256"))return 2;if(r&&!s&&void 0===i)return 0;const o=i||0;if("dumb"===n.TERM)return o;if("win32"===process.platform){const r=e.release().split(".");return Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in n)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(e=>e in n)||"codeship"===n.CI_NAME?1:o;if("TEAMCITY_VERSION"in n)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(n.TEAMCITY_VERSION)?1:0;if("truecolor"===n.COLORTERM)return 3;if("TERM_PROGRAM"in n){const e=parseInt((n.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(n.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n.TERM)||"COLORTERM"in n?1:o}return t("no-color")||t("no-colors")||t("color=false")||t("color=never")?i=0:(t("color")||t("colors")||t("color=true")||t("color=always"))&&(i=1),"FORCE_COLOR"in n&&(i="true"===n.FORCE_COLOR?1:"false"===n.FORCE_COLOR?0:0===n.FORCE_COLOR.length?1:Math.min(parseInt(n.FORCE_COLOR,10),3)),u={supportsColor:function(e){return c(a(e,e&&e.isTTY))},stdout:c(a(!0,r.isatty(1))),stderr:c(a(!0,r.isatty(2)))}}();e&&(e.stderr||e).level>=2&&(r.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}r.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,r)=>{const t=r.substring(6).toLowerCase().replace(/_([a-z])/g,(e,r)=>r.toUpperCase());let s=process.env[r];return s=!!/^(yes|on|true|enabled)$/i.test(s)||!/^(no|off|false|disabled)$/i.test(s)&&("null"===s?null:Number(s)),e[t]=s,e},{}),e.exports=(m||(m=1,d=function(e){function r(e){let s,n,o,i=null;function c(...e){if(!c.enabled)return;const t=c,n=Number(new Date),o=n-(s||n);t.diff=o,t.prev=s,t.curr=n,s=n,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(s,n)=>{if("%%"===s)return"%";i++;const o=r.formatters[n];if("function"==typeof o){const r=e[i];s=o.call(t,r),e.splice(i,1),i--}return s}),r.formatArgs.call(t,e),(t.log||r.log).apply(t,e)}return c.namespace=e,c.useColors=r.useColors(),c.color=r.selectColor(e),c.extend=t,c.destroy=r.destroy,Object.defineProperty(c,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(n!==r.namespaces&&(n=r.namespaces,o=r.enabled(e)),o),set:e=>{i=e}}),"function"==typeof r.init&&r.init(c),c}function t(e,t){const s=r(this.namespace+(void 0===t?":":t)+e);return s.log=this.log,s}function s(e,r){let t=0,s=0,n=-1,o=0;for(;t<e.length;)if(s<r.length&&(r[s]===e[t]||"*"===r[s]))"*"===r[s]?(n=s,o=t,s++):(t++,s++);else{if(-1===n)return!1;s=n+1,o++,t=o}for(;s<r.length&&"*"===r[s];)s++;return s===r.length}return r.debug=r,r.default=r,r.coerce=function(e){return e instanceof Error?e.stack||e.message:e},r.disable=function(){const e=[...r.names,...r.skips.map(e=>"-"+e)].join(",");return r.enable(""),e},r.enable=function(e){r.save(e),r.namespaces=e,r.names=[],r.skips=[];const t=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of t)"-"===e[0]?r.skips.push(e.slice(1)):r.names.push(e)},r.enabled=function(e){for(const t of r.skips)if(s(e,t))return!1;for(const t of r.names)if(s(e,t))return!0;return!1},r.humanize=b(),r.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(t=>{r[t]=e[t]}),r.names=[],r.skips=[],r.formatters={},r.selectColor=function(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return r.colors[Math.abs(t)%r.colors.length]},r.enable(r.load()),r}),d)(r);const{formatters:c}=e.exports;c.o=function(e){return this.inspectOpts.colors=this.useColors,i.inspect(e,this.inspectOpts).split("\n").map(e=>e.trim()).join(" ")},c.O=function(e){return this.inspectOpts.colors=this.useColors,i.inspect(e,this.inspectOpts)}}(g,g.exports)),g.exports}var C=(O||(O=1,"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?i.exports=r?e:(r=1,e={}):i.exports=v()),i.exports),R=t.getDefaultExportFromCjs(C);module.exports=R;
package/lib/errors.d.ts CHANGED
@@ -33,6 +33,10 @@ export declare enum ErrorCode {
33
33
  ComponentUnrecognized = "component-unrecognized",
34
34
  ComponentInvalidNoName = "component-invalid-no-name",
35
35
  RunScriptNotFound = "run-script-not-found",
36
+ AddNameRequired = "add-name-required",
37
+ AddInvalidName = "add-invalid-name",
38
+ AddUnsupportedType = "add-unsupported-type",
39
+ AddSourceExists = "add-source-exists",
36
40
  NewNameRequired = "new-name-required",
37
41
  NewTargetRequired = "new-target-required",
38
42
  NewDirExists = "new-dir-exists",
@@ -43,6 +47,8 @@ export declare enum ErrorCode {
43
47
  ExportNoTarget = "export-no-target",
44
48
  ExportNoMatching = "export-no-matching",
45
49
  ExportTargetNotFound = "export-target-not-found",
50
+ ExportOptionsConflict = "export-options-conflict",
51
+ UpdateTargetNotBuilt = "update-target-not-built",
46
52
  AddinUnsupportedType = "addin-unsupported-type",
47
53
  RunMissingFile = "run-missing-file",
48
54
  RunMissingMacro = "run-missing-macro",
@@ -0,0 +1,4 @@
1
+ "use strict";var e=require("./installer-DPj-zT7L.js"),t=require("./transform-build-graph-DgRrocSn.js"),r=require("./project-BPmPCkUS.js");require("assert"),require("fs");var o=require("./export-target-C0RYJqUX.js");exports.exportProject=async function(a={}){if(a.xmlOnly&&a.vbaOnly)throw new e.CliError(e.ErrorCode.ExportOptionsConflict,"--xml-only and --vba-only are mutually exclusive.");const n=!!a.completed||!!a.xmlOnly?2:3;e.env.reporter.log(e.Message.ExportProjectLoading,`[1/${n}] Loading project...`);const i=await r.loadProject();if(!a.target&&!i.manifest.target)throw new e.CliError(e.ErrorCode.ExportNoTarget,e.dedent`
2
+ No default target found for project,
3
+ use --target TYPE to export from a specific target.
4
+ `);let s,l=!1;if(i.manifest.target)a.target&&a.target!==i.manifest.target.type||(s=i.manifest.target);else{const t=a.target,r=i.manifest.name;s={type:t,name:r,path:`targets/${t}`,filename:`${e.sanitize(r)}.${t}`},l=!0}if(!s)throw new e.CliError(e.ErrorCode.ExportNoMatching,`No matching target found for type "${a.target}" in project.`);const p=await r.fetchDependencies(i);let g;try{a.completed?g=a.completed:(g=e.join(i.paths.staging,"export"),await e.mkdirsExports.ensureDir(g),await e.emptyExports.emptyDir(g),a.xmlOnly||(e.env.reporter.log(e.Message.ExportToStaging,`\n[2/3] Exporting src from "${s.filename}"`),await t.exportTo(i,s,g,a))),e.env.reporter.log(e.Message.ExportToProject,`\n[${n}/${n}] Updating project`),await o.exportTarget(s,{project:i,dependencies:p,blankTarget:l},g,{xmlOnly:a.xmlOnly,vbaOnly:a.vbaOnly})}catch(e){throw e}finally{g&&await e.removeExports.remove(g)}};
@@ -0,0 +1,4 @@
1
+ "use strict";var e=require("./installer-DPj-zT7L.js"),n=require("./index-CBGUBgfk.js"),t=require("path"),r=require("./load-from-project-ClF4qaC0.js"),o=require("./transform-build-graph-DgRrocSn.js");require("assert");var a=require("./project-BPmPCkUS.js"),s=require("./transform-target-CYhuozxP.js");async function i(t,r){const o=e.env.reporter.progress("Updating src files"),a=o.start,s=o.done;o.start=()=>{},o.done=()=>{},a(),await e.parallel(r.components.changed,e=>c(e.details.path,e),{progress:o}),await e.parallel(r.components.added,async n=>{const r=e.join(t.paths.dir,"src",n.filename);n.details.path=r,await c(r,n)},{progress:o}),await e.parallel(r.components.removed,async n=>{await e.removeExports.remove(n.details.path)},{progress:o}),await async function(t,r){for(const n of r.components.added){const r={name:n.name,path:e.join(t.paths.dir,`src/${n.filename}`)};t.manifest.src.push(r)}for(const e of r.components.removed){const n=t.manifest.src.findIndex(n=>n.name===e.name);t.manifest.src.splice(n,1)}for(let e of r.references.added)t.manifest.references.push(e);for(const e of r.references.removed){const n=t.manifest.references.findIndex(n=>n.name===e.name);t.manifest.references.splice(n,1)}await n.writeManifest(t.manifest,t.paths.dir)}(t,r),s()}async function c(n,r){const o=t.dirname(n);if(await e.mkdirsExports.ensureDir(o),await e.writeFile(n,r.code),r.binaryPath){if(!r.details.binary)throw new Error(`Binary data missing for component "${r.name}"`);await e.writeFile(e.join(o,r.binaryPath),r.details.binary)}}const p=[".frx"];async function m(n){const a=o.walk(n,{directories:!1}).filter(e=>"project.json"!==e&&!e.startsWith("target")&&!e.startsWith("staged")&&!(e=>!(""!==t.extname(e)))(e)).map(t=>e.join(n,t)),{name:s,references:i}=await async function(n){const t=e.join(n,"project.json");if(!await e.pathExistsExports.pathExists(t))return{name:"VBAProject",references:[]};return await e.jsonfileExports.readJson(t)}(n),c={},m=a.filter(e=>{if(!function(e){return p.includes(t.extname(e))}(e))return!0;const n=d(e);return c[n]=e,!1}),f=await e.parallel(m,async n=>{const o=d(n),a=r.extensionToType[t.extname(n)],s=await e.readFile(n),i=c[o]&&await e.readFile(c[o]);if(!a)throw new e.CliError(e.ErrorCode.ComponentUnrecognized,`Unrecognized component extension "${t.extname(n)}" (at "${n}").`);return new r.Component(a,s,{binary:i})},{progress:e.env.reporter.progress("Loading exported components")});return f.sort(r.byComponentName),{name:s,components:f,references:i,fromDependencies:{components:new Map,references:new Map}}}function d(e){return t.basename(e,t.extname(e))}async function f(n,r,o){let i=e.join(n.paths.build,r.filename);const c=e.join(o,"target");if(!await e.pathExistsExports.pathExists(i))throw new e.CliError(e.ErrorCode.ExportTargetNotFound,e.dedent`
2
+ Could not find built target for type "${r.type}"
3
+ (checked "${i}").
4
+ `);if(!e.env.isWindows){const n=e.join(o,"staged",r.filename);await e.pathExistsExports.pathExists(n)||(await e.mkdirsExports.ensureDir(t.dirname(n)),await e.copyExports.copy(i,n)),i=n}return await e.mkdirsExports.ensureDir(c),await a.unzip(i,c,{filter:s.filterTarget,map:s.mapTarget}),c}exports.exportTarget=async function(n,t,a,s={}){const{project:c,dependencies:p,blankTarget:d}=t,{xmlOnly:l=!1,vbaOnly:u=!1}=s;let w;if(d||u||(w=await f(c,n,a)),!l){const e=await r.loadFromProject(c,p),n=await m(a),t=function(e,n){const t={components:{added:[],changed:[],removed:[]},references:{added:[],changed:[],removed:[]}},o={components:new Map,references:new Map};for(const n of e.components)o.components.set(n.name,n);for(const n of e.references)o.references.set(n.name,n);for(const r of n.components){const n=r.name,a=o.components.get(n);o.components.delete(n),a&&e.fromDependencies.components.has(a)||(a?r.code!==a.code&&(r.details.path=a.details.path,t.components.changed.push(r)):t.components.added.push(r))}for(const e of o.components.values())t.components.removed.push(e);t.components.added.sort(r.byComponentName),t.components.changed.sort(r.byComponentName),t.components.removed.sort(r.byComponentName);for(const r of n.references){const n=r.name,a=o.references.get(n);o.references.delete(n),a&&e.fromDependencies.references.has(a)||(a?r.guid===a.guid&&r.major===a.major&&r.minor===a.minor||t.references.changed.push(r):t.references.added.push(r))}for(const e of o.references.values())t.references.removed.push(e);return t}(e,await o.toSrc(n));await i(c,t)}d||u||(await e.removeExports.remove(n.path),await e.copyExports.copy(w,n.path)),await e.removeExports.remove(a)},exports.extractTarget=f;
@@ -1,4 +1,4 @@
1
- "use strict";var t=require("./installer-CJlDenLg.js");exports.getTarget=function(e,r){let a,o=!1;if(r){if(e.manifest.target)e.manifest.target.type===r&&(a=e.manifest.target);else{const n=r,i=e.manifest.name;a={type:n,name:i,path:"target",filename:`${t.sanitize(i)}.${n}`},o=!0}if(!a)throw new t.CliError(t.ErrorCode.TargetNoMatching,`No matching target found for type "${r}" in project.`)}else e.manifest.target&&(a=e.manifest.target);if(!a)throw new t.CliError(t.ErrorCode.TargetNoDefault,t.dedent`
1
+ "use strict";var t=require("./installer-DPj-zT7L.js");exports.getTarget=function(e,r){let a,o=!1;if(r){if(e.manifest.target)e.manifest.target.type===r&&(a=e.manifest.target);else{const n=r,i=e.manifest.name;a={type:n,name:i,path:"target",filename:`${t.sanitize(i)}.${n}`},o=!0}if(!a)throw new t.CliError(t.ErrorCode.TargetNoMatching,`No matching target found for type "${r}" in project.`)}else e.manifest.target&&(a=e.manifest.target);if(!a)throw new t.CliError(t.ErrorCode.TargetNoDefault,t.dedent`
2
2
  No default target found for project.
3
3
 
4
4
  Use --target TYPE for a blank target
@@ -0,0 +1 @@
1
+ "use strict";var e,r,n=require("./_commonjsHelpers-Bjf42z7h.js");var t=function(){if(r)return e;r=1;var n=["h","min","s","ms","μs","ns"],t=["hour","minute","second","millisecond","microsecond","nanosecond"],o=[3600,60,1,1e6,1e3,1];return e=function(e,r){var s,i,u,a,c,f,m,l,p;if(s=!1,i=!1,r&&(s=r.verbose||!1,i=r.precise||!1),!Array.isArray(e)||2!==e.length)return"";if("number"!=typeof e[0]||"number"!=typeof e[1])return"";for(e[1]<0&&(p=e[0]+e[1]/1e9,e[0]=parseInt(p),e[1]=1e9*parseFloat((p%1).toPrecision(9))),l="",u=0;u<6&&(a=e[u<3?0:1],3!==u&&0!==u&&(a%=o[u-1]),2===u&&(a+=e[1]/1e9),!((c=a/o[u])>=1)||(s&&(c=Math.floor(c)),i?m=c.toString():(f=c>=10?0:2,m=c.toFixed(f)),m.indexOf(".")>-1&&"0"===m[m.length-1]&&(m=m.replace(/\.?0+$/,"")),l&&(l+=" "),l+=m,s?(l+=" "+t[u],"1"!==m&&(l+="s")):l+=" "+n[u],s));u++);return l}}(),o=n.getDefaultExportFromCjs(t);exports.time=o;
@@ -0,0 +1,13 @@
1
+ "use strict";var e=require("./installer-DPj-zT7L.js"),t=require("path");async function n(e){const{parse:t}=await Promise.resolve().then(function(){return require("./toml-patch-r8oqFm0h.js")});return t(e)}const r='Example vbaproject.toml:\n\n [dependencies]\n a = "^1.0.0"\n b = { version = "^0.1.0" }\n c = { path = "packages/c" }\n d = { git = "https://github.com/author/d" }\n e = { git = "https://github.com/author/e", branch = "next" }\n f = { git = "https://github.com/author/f", tag = "v1.0.0" }\n g = { git = "https://github.com/author/g", rev = "a1b2c3d4" }\n\n [dependencies.h]\n version = "^2.0.0"';function a(n,a){return Object.entries(n).map(([n,i])=>function(n,a,i){e.isString(a)&&(a={version:a});let{registry:s="vba-blocks",version:o,path:c,git:p,tag:l,branch:u="master",rev:m}=a;return e.manifestOk(o||c||p,`Invalid dependency <${n}>, no version, path, or git specified. \n\n${r}`),o?{name:n,registry:s,version:o}:c?{name:n,path:e.trailing(e.join(i,c))}:(p=function(e){return".git"===t.extname(e)?e:`${e}.git`}(p),m?{name:n,git:p,rev:m}:l?{name:n,git:p,tag:l}:{name:n,git:p,branch:u})}(n,i,a))}function i(t){return e.has(t,"registry")}function s(t){return e.has(t,"path")}function o(t,n){const r={};return t.forEach(t=>{if(i(t)){const{name:e,registry:n,version:a}=t;r[e]="vba-blocks"!==n?{version:a,registry:n}:a}else if(s(t)){let{name:a,path:i}=t;i=e.relative(n,i),r[a]={path:i}}else{const{name:e,git:n,tag:a,branch:i,rev:s}=t;r[e]={name:e,git:n},a&&(r[e].tag=a),i&&(r[e].branch=i),s&&(r[e].rev=s)}}),r}const c=/^(\d+)\.(\d+)$/,p=/\{.{8}-.{4}-.{4}-.{4}-.{12}\}/,l=e=>parseInt(e,10),u='Example vbaproject.toml:\n\n [references.Scripting]\n version = "1.0"\n guid = "{420B2830-E718-11CF-893D-00A0C9054228}"';function m(t){return Object.entries(t).map(([t,n])=>function(t,n){const{version:r,guid:a}=n;e.manifestOk((e=>c.test(e))(r),`Reference <${t}> has an invalid version <${r}>. \n\n${u}.`),e.manifestOk((e=>p.test(e))(a),`Reference <${t}> has an invalid guid <${a}>. \n\n${u}.`);const{major:i,minor:s}=(e=>{const[t,n]=e.split(".",2).map(l);return{major:t,minor:n}})(r);return{name:t,guid:a,major:i,minor:s}}(t,n))}function d(e){const t={};return e.forEach(e=>{const{name:n,guid:r,major:a,minor:i}=e,s=`${a}.${i}`;t[n]={version:s,guid:r}}),t}const f='Example vbaproject.toml:\n\n [src]\n A = "src/a.bas"\n B = { path = "src/b.cls" }',g=/^(bas|cls|frm|doccls)$/i;function h(t,n){return Object.entries(t).map(([t,r])=>function(t,n,r){e.isString(n)&&(n={path:n});const{path:a,binary:i}=n;if(!a){const r=Object.keys(n).find(e=>g.test(e));r&&e.manifestOk(!1,e.dedent`
2
+ src key <${t}.${r}> should not include the file extension.
3
+ You want to use a <${t}> instead.
4
+ `)}e.manifestOk(a,`src <${t}> is missing path. \n\n${f}`);const s=e.join(r,a),o={name:t,path:s};i&&(o.binary=e.join(r,i));return o}(t,r,n))}function v(t,n){const r={};return t.forEach(t=>{let{name:a,path:i}=t;i=e.relative(n,i),r[a]=i}),r}const b=["xlsx","xlsm","xlam"];function j(t,n,r){e.isString(t)&&(t={type:t}),e.has(t,"name")||(t={name:n,...t});const{type:a,name:i,path:s="target"}=t;e.manifestOk(e.isString(a),'Target is missing <type>. \n\nExample vbaproject.toml:\n\n [project]\n target = "xlsm"\n\nExample vbaproject.toml with alternative path:\n\n [project]\n target = { type = "xlsm", path = "target/xlsm" }.'),e.manifestOk(function(t){return e.isString(t)&&b.includes(t)}(a),`Unsupported target type <${a}>. Only <xlsx>, <xlsm>, and <xlam> are supported currently.`);return{name:i,type:a,path:e.join(r,s),filename:`${e.sanitize(i)}.${a}`}}const y="UNVERSIONED",$='Example vbaproject.toml for a package (e.g. library to be shared):\n\n [package]\n name = "my-package"\n version = "0.0.0"\n authors = ["..."]\n\nExample vbaproject.toml for a project (e.g. workbook, document, etc.):\n\n [project]\n name = "my-project"\n target = "xlsm"';function x(t,n){let r,i,s,o,c,p;e.manifestOk(t&&(t.package||t.project),`A [package] or [project] section is required. \n\n${$}`);let l={};if(t.project){const{name:a,version:u,authors:m,publish:d,target:f,...g}=t.project;r="project",i=a,s=u||y,o=m,c=d,l=g,e.manifestOk(i,`[project] name is a required field. \n\n${$}`),e.manifestOk(t.project.target,`[project] target is a required field. \n\n${$}`),p=j(f,i,n)}else{const{name:a,version:u,authors:m,publish:d,target:f,...g}=t.package;r="package",i=a,s=u,o=m,c=d,l=g,e.manifestOk(i,`[package] name is a required field. \n\n${$}`),e.manifestOk(s,`[package] version is a required field. \n\n${$}`),e.manifestOk(o,`[package] authors is a required field. \n\n${$}`),p=f&&j(f,i,n)}const u=h(t.src||{},n),d=a(t.dependencies||{},n),f=m(t.references||{}),g=h(t["dev-src"]||{},n),v=a(t["dev-dependencies"]||{},n),b=m(t["dev-references"]||{});return{type:r,name:i,version:s,metadata:{authors:o,publish:c,...l},src:u,dependencies:d,references:f,devSrc:g,devDependencies:v,devReferences:b,target:p}}exports.isGitDependency=function(t){return e.has(t,"git")},exports.isPathDependency=s,exports.isRegistryDependency=i,exports.loadManifest=async function(t){let r=e.join(t,"vbaproject.toml");if(!await e.pathExistsExports.pathExists(r)){const n=e.join(t,"vba-block.toml");if(!await e.pathExistsExports.pathExists(n))throw new e.CliError(e.ErrorCode.ManifestNotFound,e.dedent`
5
+ vbaproject.toml not found in "${t}".
6
+
7
+ Try "vbapm init" to start a new project in this directory
8
+ or "cd YOUR_PROJECTS_DIRECTORY" to change to a folder that contains an existing project.
9
+ `);r=n}const a=await e.readFile(r);let i;try{i=await n(a.toString())}catch(t){throw new e.CliError(e.ErrorCode.ManifestInvalid,e.dedent`
10
+ vbaproject.toml is invalid:
11
+
12
+ Syntax Error: ${r} (${null==t?void 0:t.line}:${null==t?void 0:t.column})\n\n${(null==t?void 0:t.message)||t}
13
+ `)}return x(i,e.normalize(t))},exports.parse=n,exports.parseManifest=x,exports.toLockfile=function t(n,r=0){if(e.isString(n))return`"${n}"`;if(e.isNumber(n))return`${n}`;if(e.isBoolean(n))return n?"true":"false";if(e.isDate(n))return n.toISOString();if(e.isObject(n)){let e="";if(0===r)for(const[a,i]of Object.entries(n))Array.isArray(i)?i.forEach(n=>{e+=`[[${a}]]\n${t(n,r+1)}\n`}):e+=`[${a}]\n${t(i,r+1)}\n`;else if(1===r)for(const[a,i]of Object.entries(n))if(Array.isArray(i)){const n=0===i.length;e+=`${a} = [\n`,e+=i.map(e=>` ${t(e,r+1)}`).join(",\n"),e+=n?"]\n":",\n]\n"}else e+=`${a} = ${t(i,r+1)}\n`;return e}throw new Error("Unsupported type passed to toLockfile. Only String, Number, Boolean, Date, Array, and Object are supported")},exports.writeManifest=async function(t,n){const r=function(t,n){const{type:r,name:a,version:i,metadata:{authors:s,publish:c,...p}}=t,l={name:a};i!==y&&(l.version=i);null!=s&&(l.authors=s);null!=c&&(l.publish=c);Object.assign(l,p);const u={[r]:l};t.target&&(u[r].target=function(t,n,r){let a,{name:i,type:s,path:o}=t;return o=e.relative(r,o),i!==n||"target"!==o?(a={type:s},i!==n&&(a.name=i),"target"!==o&&(a.path=o)):a=s,a}(t.target,t.name,n));u.src=v(t.src,n),t.dependencies.length&&(u.dependencies=o(t.dependencies,n));t.references.length&&(u.references=d(t.references));t.devSrc.length&&(u["dev-src"]=v(t.devSrc,n));t.devDependencies.length&&(u["dev-dependencies"]=o(t.devDependencies,n));t.devReferences.length&&(u["dev-references"]=d(t.devReferences));return u}(t,n),a=e.join(n,"vbaproject.toml");let i;if(await e.pathExistsExports.pathExists(a)){const t=await e.readFile(a,"utf8");i=await async function(e,t){const{patch:n}=await Promise.resolve().then(function(){return require("./toml-patch-r8oqFm0h.js")});return n(e,t)}(t,r)}else i=await async function(e){const{stringify:t}=await Promise.resolve().then(function(){return require("./toml-patch-r8oqFm0h.js")});return t(e)}(r);await e.writeFile(a,i)};