vbapm 0.6.15 → 0.7.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.
- package/README.md +46 -0
- package/addins/build/vbapm.xlam +0 -0
- package/lib/actions/add-source.d.ts +11 -0
- package/lib/add-source-_Z4tr2ea.js +17 -0
- package/lib/bin/vbapm-add.d.ts +2 -0
- package/lib/build-project-CIZanDh1.js +3 -0
- package/lib/{build-target-D6L5nsgt.js → build-target-B03OPzeI.js} +1 -1
- package/lib/{create-project-CPIRr0DV.js → create-project-CTAlegO8.js} +1 -1
- package/lib/debug.js +1 -1
- package/lib/errors.d.ts +4 -0
- package/lib/export-project-DdTYRyAw.js +4 -0
- package/lib/export-target-CEupP86g.js +4 -0
- package/lib/{get-target-CH6IpAa1.js → get-target-Ba_ZoGUl.js} +1 -1
- package/lib/index-CB6KQLC7.js +13 -0
- package/lib/{index-D-khpcjL.js → index-Cwtynogk.js} +9 -9
- package/lib/index-_8uEunjn.js +6 -0
- package/lib/{index-Dg07BXJE.js → index-mBZsirl0.js} +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -1
- package/lib/init-project-BY-a8CIk.js +15 -0
- package/lib/installer-C0iBwEpK.js +9 -0
- package/lib/{load-from-project-Bpb6Ne_i.js → load-from-project-wNJg8fme.js} +1 -1
- package/lib/one_ini_bg.wasm +0 -0
- package/lib/project-DFh-2QTw.js +20 -0
- package/lib/{run-macro-D_9-BO3U.js → run-macro-Ck_8Iku3.js} +1 -1
- package/lib/sat-solver-CqS8Vf6C.js +1 -0
- package/lib/test-project-CM-XUOdH.js +1 -0
- package/lib/toml-patch-r8oqFm0h.js +3 -0
- package/lib/transform-target-DJmqMjY0.js +2 -0
- package/lib/vbapm-add-QPN5uEGK.js +16 -0
- package/lib/vbapm-build-BKtQ6OeP.js +9 -0
- package/lib/vbapm-export-4H_qDinP.js +7 -0
- package/lib/{vbapm-init-csKsZ87H.js → vbapm-init-BMY4x_xq.js} +1 -1
- package/lib/{vbapm-new-Dt0tX1xQ.js → vbapm-new-DLW9SdvJ.js} +1 -1
- package/lib/{vbapm-run-Ccciwg2y.js → vbapm-run-DzRxAhlD.js} +2 -2
- package/lib/{vbapm-test-u7AWC-AV.js → vbapm-test-DInh0MDC.js} +1 -1
- package/lib/vbapm-version-3Xv7JjGv.js +8 -0
- package/lib/vbapm.js +2 -1
- package/package.json +124 -137
- package/lib/build-project-BczswKQl.js +0 -3
- package/lib/export-project-DQ3bfvbV.js +0 -4
- package/lib/export-target-CN6RA_mA.js +0 -4
- package/lib/index-DXFu_Z-o.js +0 -6
- package/lib/init-project-dRuDA4YO.js +0 -15
- package/lib/installer-CJlDenLg.js +0 -9
- package/lib/project-C3bWzV0O.js +0 -29
- package/lib/sat-solver-5AniWyxz.js +0 -1
- package/lib/test-project-BTkTNZXs.js +0 -1
- package/lib/toml-patch.es-CxrbsPnB.js +0 -3
- package/lib/transform-target-Doak2S1q.js +0 -2
- package/lib/vbapm-build-B1OOy6VL.js +0 -9
- package/lib/vbapm-export-vvUDCDqi.js +0 -7
- 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.
|
|
@@ -305,6 +339,18 @@ Scripting = { version = "1.0", guid = "{...}" }
|
|
|
305
339
|
<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
340
|
<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
341
|
|
|
342
|
+
### Install local version
|
|
343
|
+
|
|
344
|
+
To install the local version you can use the `devinstall.ps1` script available in the installer submodule.
|
|
345
|
+
|
|
346
|
+
```powershell
|
|
347
|
+
# Update submodule
|
|
348
|
+
git submodule update --init --recursive installer
|
|
349
|
+
|
|
350
|
+
# Run devinstall
|
|
351
|
+
.\installer\devinstall.ps1
|
|
352
|
+
```
|
|
353
|
+
|
|
308
354
|
### Release
|
|
309
355
|
|
|
310
356
|
1. Run `npm version`
|
package/addins/build/vbapm.xlam
CHANGED
|
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>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";var e=require("./installer-C0iBwEpK.js"),r=require("./index-CB6KQLC7.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}};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";var e=require("./installer-C0iBwEpK.js"),r=require("./project-DFh-2QTw.js"),t=require("./index-CB6KQLC7.js"),i=require("./build-target-B03OPzeI.js");require("assert"),require("./transform-target-DJmqMjY0.js"),require("fs");var n=require("./get-target-Ba_ZoGUl.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)};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var t=require("./installer-
|
|
1
|
+
"use strict";var t=require("./installer-C0iBwEpK.js"),a=require("./transform-target-DJmqMjY0.js");require("assert");var r=require("./load-from-project-wNJg8fme.js"),e=require("path"),i=require("./project-DFh-2QTw.js");const o=t=>/1004/.test(t),n=(a,r)=>t.dedent`
|
|
2
2
|
Failed to build target "${a.name}", it is currently open.
|
|
3
3
|
|
|
4
4
|
Please close "${r}" and try again.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var r=require("./installer-
|
|
1
|
+
"use strict";var r=require("./installer-C0iBwEpK.js"),e=require("./init-project-BY-a8CIk.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,
|
|
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} [0m`;t[0]=o+t[0].split("\n").join("\n"+o),t.push(n+"m+"+e.exports.humanize(this.diff)+"[0m")}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",
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";var e=require("./installer-C0iBwEpK.js"),t=require("./transform-target-DJmqMjY0.js"),r=require("./project-DFh-2QTw.js");require("assert"),require("fs");var a=require("./export-target-CEupP86g.js");exports.exportProject=async function(o={}){e.env.reporter.log(e.Message.ExportProjectLoading,"[1/3] Loading project...");const i=await r.loadProject();if(!o.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 n,s=!1;if(i.manifest.target)o.target&&o.target!==i.manifest.target.type||(n=i.manifest.target);else{const t=o.target,r=i.manifest.name;n={type:t,name:r,path:`targets/${t}`,filename:`${e.sanitize(r)}.${t}`},s=!0}if(!n)throw new e.CliError(e.ErrorCode.ExportNoMatching,`No matching target found for type "${o.target}" in project.`);const p=await r.fetchDependencies(i);let g;try{o.completed?g=o.completed:(g=e.join(i.paths.staging,"export"),e.env.reporter.log(e.Message.ExportToStaging,`\n[2/3] Exporting src from "${n.filename}"`),await e.mkdirsExports.ensureDir(g),await e.emptyExports.emptyDir(g),await t.exportTo(i,n,g,o)),e.env.reporter.log(e.Message.ExportToProject,"\n[3/3] Updating project"),await a.exportTarget(n,{project:i,dependencies:p,blankTarget:s},g)}catch(e){throw e}finally{g&&await e.removeExports.remove(g)}};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";var e=require("./installer-C0iBwEpK.js"),n=require("./index-CB6KQLC7.js"),t=require("path"),r=require("./load-from-project-wNJg8fme.js"),o=require("./transform-target-DJmqMjY0.js");require("assert");var a=require("./project-DFh-2QTw.js");async function s(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=>i(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 i(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 i(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 c=[".frx"];async function p(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),p={},d=a.filter(e=>{if(!function(e){return c.includes(t.extname(e))}(e))return!0;const n=m(e);return p[n]=e,!1}),f=await e.parallel(d,async n=>{const o=m(n),a=r.extensionToType[t.extname(n)],s=await e.readFile(n),i=p[o]&&await e.readFile(p[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 m(e){return t.basename(e,t.extname(e))}async function d(n,r,s){let i=e.join(n.paths.build,r.filename);const c=e.join(s,"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(s,"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:o.filterTarget,map:o.mapTarget}),c}exports.exportTarget=async function(n,t,a){const{project:i,dependencies:c,blankTarget:m}=t;let f;m||(f=await d(i,n,a));const l=await r.loadFromProject(i,c),u=await p(a),w=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}(l,await o.toSrc(u));await s(i,w),m||(await e.removeExports.remove(n.path),await e.copyExports.copy(f,n.path)),await e.removeExports.remove(a)},exports.extractTarget=d;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var t=require("./installer-
|
|
1
|
+
"use strict";var t=require("./installer-C0iBwEpK.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,13 @@
|
|
|
1
|
+
"use strict";var e=require("./installer-C0iBwEpK.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:u,branch:l="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}:u?{name:n,git:p,tag:u}:{name:n,git:p,branch:l})}(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}\}/,u=e=>parseInt(e,10),l='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${l}.`),e.manifestOk((e=>p.test(e))(a),`Reference <${t}> has an invalid guid <${a}>. \n\n${l}.`);const{major:i,minor:s}=(e=>{const[t,n]=e.split(".",2).map(u);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 j=["xlsx","xlsm","xlam"];function b(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)&&j.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${$}`),t.project?(r="project",i=t.project.name,s=t.project.version||y,o=t.project.authors,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=b(t.project.target,i,n)):(r="package",i=t.package.name,s=t.package.version,o=t.package.authors,c=t.package.publish,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=t.package.target&&b(t.package.target,i,n));return{type:r,name:i,version:s,metadata:{authors:o,publish:c},src:h(t.src||{},n),dependencies:a(t.dependencies||{},n),references:m(t.references||{}),devSrc:h(t["dev-src"]||{},n),devDependencies:a(t["dev-dependencies"]||{},n),devReferences:m(t["dev-references"]||{}),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,u={name:a};i!==y&&(u.version=i);null!=s&&(u.authors=s);null!=c&&(u.publish=c);Object.assign(u,p);const l={[r]:u};t.target&&(l[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));l.src=v(t.src,n),t.dependencies.length&&(l.dependencies=o(t.dependencies,n));t.references.length&&(l.references=d(t.references));t.devSrc.length&&(l["dev-src"]=v(t.devSrc,n));t.devDependencies.length&&(l["dev-dependencies"]=o(t.devDependencies,n));t.devReferences.length&&(l["dev-references"]=d(t.devReferences));return l}(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)};
|