vbapm 0.6.3-alpha → 0.6.12

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 (193) hide show
  1. package/README.md +57 -14
  2. package/lib/_commonjsHelpers-553b27b3.js +1 -2
  3. package/lib/{src/build → build}/component.d.ts +0 -1
  4. package/lib/build-project-59d26ffa.js +3 -0
  5. package/lib/build-target-d6327f6f.js +9 -0
  6. package/lib/{src/config.d.ts → config.d.ts} +2 -2
  7. package/lib/create-project-0813adf7.js +10 -0
  8. package/lib/debug.js +1 -2
  9. package/lib/{src/env.d.ts → env.d.ts} +1 -0
  10. package/lib/{export-project-55168787.js → export-project-59836888.js} +1 -2
  11. package/lib/export-target-902b2548.js +4 -0
  12. package/lib/get-target-cf4af796.js +11 -0
  13. package/lib/index-4386ff9f.js +5 -0
  14. package/lib/index-4ce3d28b.js +6 -0
  15. package/lib/index-72c1a91d.js +3 -0
  16. package/lib/index-c5b5f6d1.js +2 -0
  17. package/lib/{src/index.d.ts → index.d.ts} +1 -0
  18. package/lib/index.js +1 -2
  19. package/lib/init-project-74a9b860.js +15 -0
  20. package/lib/installer-2f42d28c.js +21 -0
  21. package/lib/installer.d.ts +8 -0
  22. package/lib/load-from-project-6be3cab9.js +5 -0
  23. package/lib/{src/lockfile → lockfile}/lockfile.d.ts +2 -2
  24. package/lib/once-5205b917.js +1 -0
  25. package/lib/project-d784a14d.js +29 -0
  26. package/lib/{src/resolve → resolve}/resolver.d.ts +1 -1
  27. package/lib/run-macro-c5a7bb2d.js +1 -0
  28. package/lib/sat-solver-01db5ebc.js +1 -0
  29. package/lib/test-project-b0a5536b.js +1 -0
  30. package/lib/tmp-14f9d850.js +9 -0
  31. package/lib/toml-patch.es-6bd2145d.js +1 -2
  32. package/lib/{src/utils → utils}/fs.d.ts +0 -1
  33. package/lib/{src/utils → utils}/hash.d.ts +0 -1
  34. package/lib/{src/utils → utils}/run.d.ts +1 -1
  35. package/lib/{src/utils → utils}/xml.d.ts +0 -1
  36. package/lib/{src/utils → utils}/zip.d.ts +0 -1
  37. package/lib/vbapm-build-8e2c88c7.js +9 -0
  38. package/lib/vbapm-export-af350c94.js +7 -0
  39. package/lib/vbapm-init-131ea380.js +16 -0
  40. package/lib/vbapm-new-e3409051.js +17 -0
  41. package/lib/vbapm-run-795f5167.js +10 -0
  42. package/lib/vbapm-test-dc8aad3b.js +15 -0
  43. package/lib/vbapm-version-3b5a838c.js +8 -0
  44. package/lib/vbapm.js +34 -0
  45. package/lib/workbook-xml-5b96eac5.js +2 -0
  46. package/package.json +61 -35
  47. package/run-scripts/run.ps1 +88 -81
  48. package/lib/_commonjsHelpers-553b27b3.js.map +0 -1
  49. package/lib/build-project-55e5df48.js +0 -4
  50. package/lib/build-project-55e5df48.js.map +0 -1
  51. package/lib/build-target-283e1e7d.js +0 -10
  52. package/lib/build-target-283e1e7d.js.map +0 -1
  53. package/lib/create-project-905598ca.js +0 -11
  54. package/lib/create-project-905598ca.js.map +0 -1
  55. package/lib/debug.js.map +0 -1
  56. package/lib/export-project-55168787.js.map +0 -1
  57. package/lib/export-target-c9ddd2fa.js +0 -5
  58. package/lib/export-target-c9ddd2fa.js.map +0 -1
  59. package/lib/get-target-23b8cc04.js +0 -12
  60. package/lib/get-target-23b8cc04.js.map +0 -1
  61. package/lib/index-35cff1d5.js +0 -38
  62. package/lib/index-35cff1d5.js.map +0 -1
  63. package/lib/index-87f55e79.js +0 -4
  64. package/lib/index-87f55e79.js.map +0 -1
  65. package/lib/index-b49bd5b2.js +0 -2
  66. package/lib/index-b49bd5b2.js.map +0 -1
  67. package/lib/index-c97017db.js +0 -2
  68. package/lib/index-c97017db.js.map +0 -1
  69. package/lib/index-d9ba3ba0.js +0 -6
  70. package/lib/index-d9ba3ba0.js.map +0 -1
  71. package/lib/index-ffbba08f.js +0 -3
  72. package/lib/index-ffbba08f.js.map +0 -1
  73. package/lib/index.js.map +0 -1
  74. package/lib/inherits-713f4554.js +0 -2
  75. package/lib/inherits-713f4554.js.map +0 -1
  76. package/lib/init-project-a62cb644.js +0 -16
  77. package/lib/init-project-a62cb644.js.map +0 -1
  78. package/lib/load-from-project-e6530a69.js +0 -6
  79. package/lib/load-from-project-e6530a69.js.map +0 -1
  80. package/lib/minimatch-3a1d1fa9.js +0 -2
  81. package/lib/minimatch-3a1d1fa9.js.map +0 -1
  82. package/lib/once-9eb67b4f.js +0 -2
  83. package/lib/once-9eb67b4f.js.map +0 -1
  84. package/lib/project-d43b4e0c.js +0 -30
  85. package/lib/project-d43b4e0c.js.map +0 -1
  86. package/lib/run-macro-f4aa7c14.js +0 -2
  87. package/lib/run-macro-f4aa7c14.js.map +0 -1
  88. package/lib/sat-solver-01d6409e.js +0 -2
  89. package/lib/sat-solver-01d6409e.js.map +0 -1
  90. package/lib/src/installer.d.ts +0 -3
  91. package/lib/test-project-d4f237d1.js +0 -2
  92. package/lib/test-project-d4f237d1.js.map +0 -1
  93. package/lib/text-ba532b40.js +0 -10
  94. package/lib/text-ba532b40.js.map +0 -1
  95. package/lib/tmp-bc08ebcf.js +0 -10
  96. package/lib/tmp-bc08ebcf.js.map +0 -1
  97. package/lib/toml-patch.es-6bd2145d.js.map +0 -1
  98. package/lib/vba-blocks-build-a717fcdb.js +0 -10
  99. package/lib/vba-blocks-build-a717fcdb.js.map +0 -1
  100. package/lib/vba-blocks-export-7e2c75cc.js +0 -8
  101. package/lib/vba-blocks-export-7e2c75cc.js.map +0 -1
  102. package/lib/vba-blocks-init-54531020.js +0 -17
  103. package/lib/vba-blocks-init-54531020.js.map +0 -1
  104. package/lib/vba-blocks-new-3210d92c.js +0 -18
  105. package/lib/vba-blocks-new-3210d92c.js.map +0 -1
  106. package/lib/vba-blocks-run-ab9d4ad4.js +0 -11
  107. package/lib/vba-blocks-run-ab9d4ad4.js.map +0 -1
  108. package/lib/vba-blocks-test-da5dba90.js +0 -16
  109. package/lib/vba-blocks-test-da5dba90.js.map +0 -1
  110. package/lib/vba-blocks-version-e1b3c35a.js +0 -9
  111. package/lib/vba-blocks-version-e1b3c35a.js.map +0 -1
  112. package/lib/vba-blocks.js +0 -43
  113. package/lib/vba-blocks.js.map +0 -1
  114. package/lib/workbook-xml-69fff4ae.js +0 -3
  115. package/lib/workbook-xml-69fff4ae.js.map +0 -1
  116. /package/lib/{src/actions → actions}/build-project.d.ts +0 -0
  117. /package/lib/{src/actions → actions}/create-project.d.ts +0 -0
  118. /package/lib/{src/actions → actions}/export-project.d.ts +0 -0
  119. /package/lib/{src/actions → actions}/increment-version.d.ts +0 -0
  120. /package/lib/{src/actions → actions}/init-project.d.ts +0 -0
  121. /package/lib/{src/actions → actions}/run-macro.d.ts +0 -0
  122. /package/lib/{src/actions → actions}/test-project.d.ts +0 -0
  123. /package/lib/{src/addin.d.ts → addin.d.ts} +0 -0
  124. /package/lib/{src/bin/vba-blocks-build.d.ts → bin/vbapm-build.d.ts} +0 -0
  125. /package/lib/{src/bin/vba-blocks-export.d.ts → bin/vbapm-export.d.ts} +0 -0
  126. /package/lib/{src/bin/vba-blocks-init.d.ts → bin/vbapm-init.d.ts} +0 -0
  127. /package/lib/{src/bin/vba-blocks-new.d.ts → bin/vbapm-new.d.ts} +0 -0
  128. /package/lib/{src/bin/vba-blocks-run.d.ts → bin/vbapm-run.d.ts} +0 -0
  129. /package/lib/{src/bin/vba-blocks-test.d.ts → bin/vbapm-test.d.ts} +0 -0
  130. /package/lib/{src/bin/vba-blocks-version.d.ts → bin/vbapm-version.d.ts} +0 -0
  131. /package/lib/{src/bin/vba-blocks.d.ts → bin/vbapm.d.ts} +0 -0
  132. /package/lib/{src/build → build}/apply-changeset.d.ts +0 -0
  133. /package/lib/{src/build → build}/build-graph.d.ts +0 -0
  134. /package/lib/{src/build → build}/changeset.d.ts +0 -0
  135. /package/lib/{src/build → build}/compare-build-graphs.d.ts +0 -0
  136. /package/lib/{src/build → build}/index.d.ts +0 -0
  137. /package/lib/{src/build → build}/load-from-export.d.ts +0 -0
  138. /package/lib/{src/build → build}/load-from-project.d.ts +0 -0
  139. /package/lib/{src/build → build}/stage-build-graph.d.ts +0 -0
  140. /package/lib/{src/build → build}/transform-build-graph.d.ts +0 -0
  141. /package/lib/{src/build → build}/transforms/editor-config.d.ts +0 -0
  142. /package/lib/{src/cache.d.ts → cache.d.ts} +0 -0
  143. /package/lib/{src/debug.d.ts → debug.d.ts} +0 -0
  144. /package/lib/{src/errors.d.ts → errors.d.ts} +0 -0
  145. /package/lib/{src/lockfile → lockfile}/index.d.ts +0 -0
  146. /package/lib/{src/lockfile → lockfile}/is-lockfile-valid.d.ts +0 -0
  147. /package/lib/{src/manifest → manifest}/dependency.d.ts +0 -0
  148. /package/lib/{src/manifest → manifest}/index.d.ts +0 -0
  149. /package/lib/{src/manifest → manifest}/reference.d.ts +0 -0
  150. /package/lib/{src/manifest → manifest}/source.d.ts +0 -0
  151. /package/lib/{src/manifest → manifest}/target.d.ts +0 -0
  152. /package/lib/{src/manifest → manifest}/version.d.ts +0 -0
  153. /package/lib/{src/messages.d.ts → messages.d.ts} +0 -0
  154. /package/lib/{src/professional → professional}/sources/git-source.d.ts +0 -0
  155. /package/lib/{src/professional → professional}/workspace.d.ts +0 -0
  156. /package/lib/{src/project.d.ts → project.d.ts} +0 -0
  157. /package/lib/{src/reporter.d.ts → reporter.d.ts} +0 -0
  158. /package/lib/{src/resolve → resolve}/dependency-graph.d.ts +0 -0
  159. /package/lib/{src/resolve → resolve}/index.d.ts +0 -0
  160. /package/lib/{src/resolve → resolve}/latest-solver.d.ts +0 -0
  161. /package/lib/{src/resolve → resolve}/sat-solver.d.ts +0 -0
  162. /package/lib/{src/sources → sources}/index.d.ts +0 -0
  163. /package/lib/{src/sources → sources}/path-source.d.ts +0 -0
  164. /package/lib/{src/sources → sources}/registration.d.ts +0 -0
  165. /package/lib/{src/sources → sources}/registry-source.d.ts +0 -0
  166. /package/lib/{src/sources → sources}/source.d.ts +0 -0
  167. /package/lib/{src/targets → targets}/add-target.d.ts +0 -0
  168. /package/lib/{src/targets → targets}/build-target.d.ts +0 -0
  169. /package/lib/{src/targets → targets}/export-target.d.ts +0 -0
  170. /package/lib/{src/targets → targets}/get-target.d.ts +0 -0
  171. /package/lib/{src/targets → targets}/index.d.ts +0 -0
  172. /package/lib/{src/targets → targets}/project-info.d.ts +0 -0
  173. /package/lib/{src/targets → targets}/transform-target.d.ts +0 -0
  174. /package/lib/{src/targets → targets}/transforms/core-xml.d.ts +0 -0
  175. /package/lib/{src/targets → targets}/transforms/workbook-xml.d.ts +0 -0
  176. /package/lib/{src/utils → utils}/async-map.d.ts +0 -0
  177. /package/lib/{src/utils → utils}/download.d.ts +0 -0
  178. /package/lib/{src/utils → utils}/get-staging.d.ts +0 -0
  179. /package/lib/{src/utils → utils}/git.d.ts +0 -0
  180. /package/lib/{src/utils → utils}/github.d.ts +0 -0
  181. /package/lib/{src/utils → utils}/has.d.ts +0 -0
  182. /package/lib/{src/utils → utils}/interop.d.ts +0 -0
  183. /package/lib/{src/utils → utils}/is.d.ts +0 -0
  184. /package/lib/{src/utils → utils}/noop.d.ts +0 -0
  185. /package/lib/{src/utils → utils}/observable.d.ts +0 -0
  186. /package/lib/{src/utils → utils}/parallel.d.ts +0 -0
  187. /package/lib/{src/utils → utils}/path.d.ts +0 -0
  188. /package/lib/{src/utils → utils}/pipe.d.ts +0 -0
  189. /package/lib/{src/utils → utils}/stdout-file.d.ts +0 -0
  190. /package/lib/{src/utils → utils}/text.d.ts +0 -0
  191. /package/lib/{src/utils → utils}/toml.d.ts +0 -0
  192. /package/lib/{src/utils → utils}/unique.d.ts +0 -0
  193. /package/lib/{src/utils → utils}/without.d.ts +0 -0
@@ -0,0 +1,8 @@
1
+ export declare function updateVersion(): string | undefined;
2
+ export declare function updateAvailable(): boolean;
3
+ export declare function checkForUpdate(): Promise<boolean>;
4
+ /**
5
+ * Detect if both standalone CLI and npm global installations exist.
6
+ * Returns a warning message if both are found, or undefined if only one is present.
7
+ */
8
+ export declare function checkDualInstall(): string | undefined;
@@ -0,0 +1,5 @@
1
+ "use strict";var e=require("./installer-2f42d28c.js"),n=require("path");class t{constructor(e,n,t={}){this.type=e,this.code=n&&Buffer.isBuffer(n)?n.toString():n,this.details=t}get name(){const n=r(this.code,"Attribute VB_Name");if(!n)throw new e.CliError(e.ErrorCode.ComponentInvalidNoName,"Invalid component: No attribute VB_Name found.");const[t,o]=n.split("=");return JSON.parse(o)}get binaryPath(){const e=r(this.code,"OleObjectBlob");if(!e)return;const[n,t]=e.split("=",2),[o,s]=t.split(":",2);return JSON.parse(o)}get filename(){const e=s[this.type];return`${this.name}${e}`}static async load(s,r={}){const{binary_path:a}=r,i=o[n.extname(s)];if(!i)throw new e.CliError(e.ErrorCode.ComponentUnrecognized,`Unrecognized component extension "${n.extname(s)}" (at "${s}").`);const c=await e.readFile(s),m=a&&await e.readFile(a);return new t(i,c,{path:s,binary:m})}}const o={".bas":"module",".cls":"class",".frm":"form"},s={module:".bas",class:".cls",form:".frm"};function r(n,t){return n.split(e.BY_LINE).map(e=>e.trim()).find(e=>e.startsWith(t))}function a(e,n){return e.name<n.name?-1:e.name>n.name?1:0}exports.Component=t,exports.byComponentName=a,exports.extensionToType=o,exports.loadFromProject=async function(n,o,s={}){let r=o;if(s.release){const e=n.manifest.devDependencies.map(e=>e.name);r=o.filter(n=>!e.includes(n.name))}const i=[n.manifest,...r],c=[],m=[],f={},p={components:new Map,references:new Map};for(const e of i){for(const o of e.src)c.push(t.load(o.path,{binary_path:o.binary}).then(t=>(e!==n.manifest&&p.components.set(t,e.name),t)));for(const t of e.references){const o=`${t.name}_${t.guid}`;f[o]||(m.push(t),e!==n.manifest&&p.references.set(t,e.name),f[o]=!0)}}if(!s.release){for(const e of n.manifest.devSrc)c.push(t.load(e.path,{binary_path:e.binary}));for(const e of n.manifest.devReferences){const n=`${e.name}_${e.guid}`;f[n]||(m.push(e),f[n]=!0)}}const l={name:"VBAProject",components:(await Promise.all(c)).sort(a),references:m,fromDependencies:p};return function(n,t){const o={},s={},r=[];for(const e of t.components){o[e.name]||(o[e.name]=[]);const s=t.fromDependencies.components.get(e)||n.manifest.name;o[e.name].push(s)}for(const e of t.references)s[e.name]||(s[e.name]=[]),s[e.name].push(e);for(const[n,t]of Object.entries(o))if(t.length>1){const o=t.map(e=>`"${e}"`);r.push(`Source "${n}" is present in manifests named ${e.joinCommas(o)}`)}for(const[n,t]of Object.entries(s))if(t.length>1){const o=t.map(e=>`${e.major}.${e.minor}`);r.push(`Reference "${n}" has multiple versions: ${e.joinCommas(o)}`)}if(r.length)throw new e.CliError(e.ErrorCode.BuildInvalid,e.dedent`
2
+ Invalid build:
3
+
4
+ ${r.join("\n")}
5
+ `)}(n,l),l};
@@ -11,8 +11,8 @@ export declare const LOCKFILE_VERSION = "1";
11
11
  * Save resolved dependency graph and workspace information
12
12
  * for precisely rebuilding dependency graph if the workspace hasn't changed
13
13
  *
14
- * Version the lockfile separately from vba-blocks to allow the lockfile format to change over time,
15
- * while staying isolated from the more-frequent changes to the vba-blocks version.
14
+ * Version the lockfile separately from vbapm to allow the lockfile format to change over time,
15
+ * while staying isolated from the more-frequent changes to the vbapm version.
16
16
  */
17
17
  export interface Lockfile {
18
18
  metadata?: {
@@ -0,0 +1 @@
1
+ "use strict";var n=function n(e,r){if(e&&r)return n(e)(r);if("function"!=typeof e)throw new TypeError("need wrapper function");return Object.keys(e).forEach(function(n){t[n]=e[n]}),t;function t(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];var t=e.apply(this,n),o=n[n.length-1];return"function"==typeof t&&t!==o&&Object.keys(o).forEach(function(n){t[n]=o[n]}),t}};var e=n(t),r=n(o);function t(n){var e=function(){return e.called?e.value:(e.called=!0,e.value=n.apply(this,arguments))};return e.called=!1,e}function o(n){var e=function(){if(e.called)throw new Error(e.onceError);return e.called=!0,e.value=n.apply(this,arguments)},r=n.name||"Function wrapped with `once`";return e.onceError=r+" shouldn't be called more than once",e.called=!1,e}t.proto=t(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return t(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:!0})}),e.strict=r,exports.once_1=e;
@@ -0,0 +1,29 @@
1
+ "use strict";var e=require("./installer-2f42d28c.js"),t=require("assert"),n=require("path"),r=require("querystring"),i=require("fs");function a(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var o=a(i);function s(e){return Array.from(new Set(e))}async function c(e,t){const n=e.root.dependencies.concat(e.root.devDependencies);await u(n,t);const r=[],i=[];for(const[e,n]of t){const e=p(n);e?r.push(e):i.push(n)}if(i.length)throw new Error("Unable to resolve dependency graph for given manifest");return r}async function u(e,t){const n=await Promise.all(e.map(e=>t.get(e)));for(const e of n){const{registered:n}=e,r=p(e)||n[n.length-1];await u(r.dependencies,t)}}function p(t){const n=s(t.range).join(" "),r=t.registered.slice().reverse();return n?r.find(t=>e.semver.satisfies(t.version,n)):r[0]}const d='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 l(t,n){return Object.entries(t).map(([t,r])=>function(t,n,r){e.isString(n)&&(n={version:n});let{registry:i="vba-blocks",version:a,path:o,git:s,tag:c,branch:u="master",rev:p}=n;return e.manifestOk(a||o||s,`Invalid dependency "${t}", no version, path, or git specified. \n\n${d}`),a?{name:t,registry:i,version:a}:o?{name:t,path:e.trailing(e.join(r,o))}:(s=v(s),p?{name:t,git:s,rev:p}:c?{name:t,git:s,tag:c}:{name:t,git:s,branch:u})}(t,r,n))}function f(t){return e.has(t,"registry")}function g(t){return e.has(t,"path")}function h(t){return e.has(t,"git")}function m(t,n){const r={};return t.forEach(t=>{if(f(t)){const{name:e,registry:n,version:i}=t;r[e]="vba-blocks"!==n?{version:i,registry:n}:i}else if(g(t)){let{name:i,path:a}=t;a=e.relative(n,a),r[i]={path:a}}else{const{name:e,git:n,tag:i,branch:a,rev:o}=t;r[e]={name:e,git:n},i&&(r[e].tag=i),a&&(r[e].branch=a),o&&(r[e].rev=o)}}),r}function v(e){return".git"===n.extname(e)?e:`${e}.git`}const y=e.dedent`
2
+ git dependencies are not currently supported.
3
+
4
+ Upgrade to Professional Edition (coming soon) for git dependencies and more.
5
+ `;class w{resolve(t){throw new e.CliError(e.ErrorCode.SourceUnsupported,y)}fetch(t){throw new e.CliError(e.ErrorCode.SourceUnsupported,y)}}async function b(e){const{parse:t}=await Promise.resolve().then(function(){return require("./toml-patch.es-6bd2145d.js")});return t(e)}function k(t,n=0){if(e.isString(t))return`"${t}"`;if(e.isNumber(t))return`${t}`;if(e.isBoolean(t))return t?"true":"false";if(e.isDate(t))return t.toISOString();if(e.isObject(t)){let e="";if(0===n)for(const[r,i]of Object.entries(t))Array.isArray(i)?i.forEach(t=>{e+=`[[${r}]]\n${k(t,n+1)}\n`}):e+=`[${r}]\n${k(i,n+1)}\n`;else if(1===n)for(const[r,i]of Object.entries(t))if(Array.isArray(i)){const t=0===i.length;e+=`${r} = [\n`,e+=i.map(e=>` ${k(e,n+1)}`).join(",\n"),e+=t?"]\n":",\n]\n"}else e+=`${r} = ${k(i,n+1)}\n`;return e}throw new Error("Unsupported type passed to toLockfile. Only String, Number, Boolean, Date, Array, and Object are supported")}const j=/^(\d+)\.(\d+)$/,$=/\{.{8}-.{4}-.{4}-.{4}-.{12}\}/,E=e=>parseInt(e,10),x='Example vbaproject.toml:\n\n [references.Scripting]\n version = "1.0"\n guid = "{420B2830-E718-11CF-893D-00A0C9054228}"';function S(t){return Object.entries(t).map(([t,n])=>function(t,n){const{version:r,guid:i}=n;e.manifestOk((e=>j.test(e))(r),`Reference "${t}" has an invalid version "${r}". \n\n${x}.`),e.manifestOk((e=>$.test(e))(i),`Reference "${t}" has an invalid guid "${i}". \n\n${x}'`);const{major:a,minor:o}=(e=>{const[t,n]=e.split(".",2).map(E);return{major:t,minor:n}})(r);return{name:t,guid:i,major:a,minor:o}}(t,n))}function C(e){const t={};return e.forEach(e=>{const{name:n,guid:r,major:i,minor:a}=e,o=`${i}.${a}`;t[n]={version:o,guid:r}}),t}const O='Example vbaproject.toml:\n\n [src]\n A = "src/a.bas"\n B = { path = "src/b.cls" }';function D(t,n){return Object.entries(t).map(([t,r])=>function(t,n,r){e.isString(n)&&(n={path:n});const{path:i,binary:a}=n;e.manifestOk(i,`src "${t}" is missing path. \n\n${O}`);const o=e.join(r,i),s={name:t,path:o};a&&(s.binary=e.join(r,a));return s}(t,r,n))}function q(t,n){const r={};return t.forEach(t=>{let{name:i,path:a}=t;a=e.relative(n,a),r[i]=a}),r}const P=["xlsx","xlsm","xlam"];function F(t,n,r){e.isString(t)&&(t={type:t}),e.has(t,"name")||(t={name:n,...t});const{type:i,name:a,path:o="target"}=t;e.manifestOk(e.isString(i),'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)&&P.includes(t)}(i),`Unsupported target type "${i}". Only "xlsx", "xlsm", and "xlam" are supported currently.`);return{name:a,type:i,path:e.join(r,o),filename:`${e.sanitize(a)}.${i}`}}const R="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 N(t,n){let r,i,a,o,s,c;e.manifestOk(t&&(t.package||t.project),`A [package] or [project] section is required. \n\n${_}`),t.project?(r="project",i=t.project.name,a=t.project.version||R,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${_}`),c=F(t.project.target,i,n)):(r="package",i=t.package.name,a=t.package.version,o=t.package.authors,s=t.package.publish,e.manifestOk(i,`[package] name is a required field. \n\n${_}`),e.manifestOk(a,`[package] version is a required field. \n\n${_}`),e.manifestOk(o,`[package] authors is a required field. \n\n${_}`),c=t.package.target&&F(t.package.target,i,n));return{type:r,name:i,version:a,metadata:{authors:o,publish:s},src:D(t.src||{},n),dependencies:l(t.dependencies||{},n),references:S(t.references||{}),devSrc:D(t["dev-src"]||{},n),devDependencies:l(t["dev-dependencies"]||{},n),devReferences:S(t["dev-references"]||{}),target:c}}async function M(t){let n=e.join(t,"vbaproject.toml");if(!await e.pathExists_1.pathExists(n)){const r=e.join(t,"vba-block.toml");if(!await e.pathExists_1.pathExists(r))throw new e.CliError(e.ErrorCode.ManifestNotFound,e.dedent`
6
+ vbaproject.toml not found in "${t}".
7
+
8
+ Try "vbapm init" to start a new project in this directory
9
+ or "cd YOUR_PROJECTS_DIRECTORY" to change to a folder that contains an existing project.
10
+ `);n=r}const r=await e.readFile(n);let i;try{i=await b(r.toString())}catch(t){throw new e.CliError(e.ErrorCode.ManifestInvalid,e.dedent`
11
+ vbaproject.toml is invalid:
12
+
13
+ Syntax Error: ${n} (${null==t?void 0:t.line}:${null==t?void 0:t.column})\n\n${(null==t?void 0:t.message)||t}
14
+ `)}return N(i,e.normalize(t))}function A(t,n){return e.isString(t)||(n=t.version,t=t.name),`${t}@${n}`}function U(e,t,n){let r=`${e}+${t}`;return n&&(r+=`#${n}`),r}function z(e){const[t,...n]=e.split("#"),[r,...i]=t.split("+");return{type:r,value:i.join("+"),details:n.join("#")}}function I(t){const{name:n,version:i,source:a}=t,{type:o,value:s,details:c}=z(a);if("registry"===o)return{name:n,version:i,registry:s};if("git"===o){return{name:n,git:s,...r.parse(c)}}if("path"===o)return{name:n,path:s,version:i};throw new e.CliError(e.ErrorCode.SourceUnrecognizedType,e.dedent`
15
+ Unrecognized source type "${o}" in registration.
16
+ ("registry", "path", and "git" are supported)
17
+ `)}class T{async resolve(t){const{name:n,path:r}=t;if(!e.pathExists_1.pathExists(r))throw new e.CliError(e.ErrorCode.DependencyPathNotFound,`Path not found for dependency "${n}" (${r}).`);const i=await M(r),{version:a,dependencies:o}=i;return[{id:A(i),source:U("path",r),name:n,version:a,dependencies:o}]}async fetch(e){const{value:t}=z(e.source);return t}}const L=e.env.debug("vbapm:git"),B={name:"vbapm",email:"vbapm@local"};async function W(){const e=await Promise.resolve().then(function(){return require("./installer-2f42d28c.js")}).then(function(e){return e.index});global.fetch=e.default;return{git:await Promise.resolve().then(function(){return require("./index-4ce3d28b.js")}),http:(await Promise.resolve().then(function(){return require("./index-c5b5f6d1.js")})).default}}async function J(e,t,n){const r=function(e){return"default"in e?e.default:e}(await Promise.resolve().then(function(){return require("./index-4386ff9f.js")}).then(function(e){return e.index}));await r(e,t,n)}const Y=e.env.debug("vbapm:registry-source");class V{constructor({name:t,index:n,packages:r}){this.name=t,this.local={index:e.join(e.env.registry,t),packages:e.join(e.env.packages,t)},this.remote={index:n,packages:r},this.sources=e.join(e.env.sources,t),this.upToDate=!1}async resolve(t){this.upToDate||await this.pull();const{name:n}=t,r=function(t,n){return e.join(t,G(n))}(this.local.index,n);if(!await e.pathExists_1.pathExists(r))throw new e.CliError(e.ErrorCode.DependencyNotFound,`Dependency "${n}" not found in registry "${this.name}".`);const i=(await e.readFile(r,"utf8")).split(/\r?\n/).filter(e=>!!e).map(e=>JSON.parse(e)).filter(e=>e&&!e.yanked).map(e=>function(e,t){const{name:n,vers:r,cksum:i}=t,a=t.deps.map(t=>{const{name:n,req:r}=t;return{name:n,registry:e,version:r}});return{id:A(n,r),source:U("registry",e,i),name:n,version:r,dependencies:a}}(this.name,e));return i}async fetch(t){const r=function(e,t){const{name:n,version:r}=t;return`${e}/${G(n)}-v${r}.block`}(this.remote.packages,t),a=function(t,n){const{name:r,version:i}=n;return e.join(t,`${G(r)}-v${i}.block`)}(this.local.packages,t),[o,s]=t.source.split("#",2),[c,u]=s.split("-");if(!await e.pathExists_1.pathExists(a)){const o=await e.tmpFile();try{await async function(t,r){return await e.mkdirs_1.ensureDir(n.dirname(r)),e.fetch(t).then(e=>{const t=i.createWriteStream(r);return new Promise((n,r)=>{e.body.pipe(t).on("finish",()=>n()).on("error",r)})})}(r,o)}catch(n){throw new e.CliError(e.ErrorCode.SourceDownloadFailed,`Failed to download "${t.source}".`,n)}const s=await e.checksum(o,c);if(s!==u)throw Y(`Checksum failed for ${o}`),Y(`Expected ${u} (${c}), received ${s}`),new e.CliError(e.ErrorCode.DependencyInvalidChecksum,e.dedent`
18
+ Dependency "${t.name}" failed validation.
19
+
20
+ The downloaded file signature for ${t.id}
21
+ does not match the signature in the registry.
22
+ `);await e.move_1.move(o,a)}const p=function(t,n){const{name:r,version:i}=n;return e.join(t,`${G(r)}-v${i}`)}(this.sources,t);await e.mkdirs_1.ensureDir(p),await J(a,p);const d=e.join(p,"vba-block.toml"),l=e.join(p,"vbaproject.toml");return i.existsSync(d)&&(i.existsSync(l)?i.unlinkSync(d):i.renameSync(d,l)),p}async pull(){if(this.pulling)return this.pulling;this.pulling=async function(t,r){const i=await e.pathExists_1.pathExists(t);if(i&&!async function(t){return await e.pathExists_1.pathExists(e.join(t,".git"))}(t))return void e.env.reporter.log(e.Message.RegistrySourceLocalOnly,"(local registry is not a git repository, skipping pull)");if(!i){await e.mkdirs_1.ensureDir(n.dirname(t));try{await async function(t,n,r){const{git:i,http:a}=await W(),s=e.join(r,n);L(`clone: ${t} to ${s}`),await i.clone({fs:o,http:a,dir:s,url:t,depth:1})}(r,n.basename(t),n.dirname(t))}catch(t){throw new e.CliError(e.ErrorCode.RegistryCloneFailed,`Failed to clone registry from ${r}`,t)}}try{await async function(e){const{git:t,http:n}=await W(),r=await t.currentBranch({fs:o,dir:e,fullname:!1});L(`pull: ${e}${r?` (${r})`:""}`),await t.pull({fs:o,http:n,dir:e,ref:r||void 0,author:B,committer:B})}(t)}catch(t){Y("Pull failed",t),e.env.reporter.log(e.Message.RegistrySourceSkipPull,"(failed to update local registry, resolving with previously loaded values)")}}(this.local.index,this.remote.index),await this.pulling,this.upToDate=!0,this.pulling=void 0}}function G(t){return e.sanitize(t.replace("/","--"))}async function H(n,r){if(f(r)){const{registry:e}=r,i=n.registry[e];return t.ok(i,Q(e)),i.resolve(r)}if(g(r))return n.path.resolve(r);if(h(r))return n.git.resolve(r);throw new e.CliError(e.ErrorCode.DependencyUnknownSource,`No source matches dependency "${r.name}".`)}async function K(n,r){const{type:i,value:a}=z(r.source);if("registry"===i){const e=n.registry[a];return t.ok(e,Q(a)),n.registry[a].fetch(r)}if("path"===i)return n.path.fetch(r);if("git"===i)return n.git.fetch(r);throw new e.CliError(e.ErrorCode.SourceNoneMatching,e.dedent`
23
+ No source matches given registration type "${i}"
24
+ (source = "${r.source}").
25
+ `)}function Q(t){return new e.CliError(e.ErrorCode.SourceMisconfiguredRegistry,`No matching registry configured for "${t}".`)}class X{constructor(e){this.config=e,this.graph=new Map,this.loading=new Map,this.preferred=new Map}async get(e){const{name:t}=e;this.loading.has(t)&&await this.loading.get(t);let n=this.graph.get(t);if(!n){const r=H(this.config.sources,e);this.loading.set(t,r);n={name:t,range:[],registered:await r},this.preferred.has(t)&&(n.preferred=this.preferred.get(t)),this.loading.delete(t),this.graph.set(t,n)}return f(e)&&n.range.push(e.version),n}getRegistration(e){const[t,n]=e.split("@",2);if(!this.graph.has(t))return;const{registered:r}=this.graph.get(t);return r.find(e=>e.version===n)}prefer(e){for(const t of e)this.preferred.set(t.name,t)}[Symbol.iterator](){return this.graph.entries()}}const Z=e.env.debug("vbapm:resolve");async function ee(t,n,r=[]){e.env.reporter.log(e.Message.DependenciesResolving,"Resolving dependencies");const i=new X(t);i.prefer(r);try{return await c(n,i)}catch(e){Z(`solveLatest failed with ${e}`)}try{const{solveSat:e}=await Promise.resolve().then(function(){return require("./sat-solver-01db5ebc.js")});return await e(n,i)}catch(e){Z(`solveSat failed with ${e}`)}throw new e.CliError(e.ErrorCode.ResolveFailed,e.dedent`
26
+ Unable to resolve dependency graph for project.
27
+
28
+ There are dependencies that cannot be satisfied.
29
+ `)}async function te(e,t){return e.name===t.name&&await async function(e,t){const n=e.dependencies.concat(e.devDependencies);if(n.length!==t.dependencies.length)return!1;const r={};n.forEach(e=>{r[e.name]=e});for(const e of t.dependencies){const t=r[e.name];if(!t)return!1;if(!await ne(t,e))return!1}return!0}(e,t)}async function ne(t,n){if(f(n))return f(t)&&e.semver.satisfies(n.version,t.version);if(g(n)){if(!g(t))return!1;if(t.path!==n.path)return!1;return(await M(t.path)).version===n.version}if(h(n)){if(!h(t))return!1;if(e.has(t,"rev")&&e.has(n,"rev"))return t.rev===n.rev;if(e.has(t,"tag")&&e.has(n,"tag"))return t.tag===n.tag;if(e.has(t,"branch")&&e.has(n,"branch"))return t.branch===n.branch}return!1}const re=e.env.debug("vbapm:lockfile");async function ie(n){const r=e.join(n,"vbaproject.lock");if(re(`Reading lockfile from ${r}`),!await e.pathExists_1.pathExists(r))return re("Not found"),null;try{const i=await e.readFile(r,"utf8");return await async function(n,r){const i=await b(n);t.ok(e.has(i,"root"),"vbaproject.lock is missing [root] field");const a=i.metadata,o=new Map,s=(i.packages||[]).map(e=>{const{name:n,version:i,source:a,dependencies:s}=e;t.ok(n&&i&&a&&Array.isArray(s),"Invalid package in lockfile");const c={id:A(n,i),name:n,version:i,source:ce(a,r),dependencies:s};return o.set(n,I(c)),c});s.forEach(e=>{e.dependencies=e.dependencies.map(e=>pe(e,o))});const c=ae(i.root,o),u=(i.members||[]).map(e=>ae(e,o));return{metadata:a,workspace:{root:c,members:u},packages:s}}(i,n)}catch(e){return re("Error reading/parsing"),re(e),null}}function ae(e,n){const{name:r}=e;t.ok(r&&Array.isArray(e.dependencies),"Invalid manifest in lockfile");return{name:r,dependencies:e.dependencies.map(e=>pe(e,n))}}function oe(e,t,n){const{name:r,version:i}=e;return{name:r,dependencies:e.dependencies.concat(e.devDependencies).map(e=>ue(e,t,n))}}function se(t,n){const{type:r,value:i,details:a}=z(t);if("path"!==r)return t;return U(r,e.trailing(e.relative(n,i)),a)}function ce(t,n){const{type:r,value:i,details:a}=z(t);if("path"!==r)return t;return U(r,e.join(n,i),a)}function ue(n,r,i){const a=function(e,t){return e.find(e=>e.name===t.name)}(r,n);t.ok(a,`No package found for dependency "${n.name}"`);let{version:o,source:s}=a;const{type:c,value:u,details:p}=z(s);if("path"===c){s=U(c,e.trailing(e.relative(i,u)),p)}return`${n.name} ${o} ${s}`}function pe(e,n){const[r]=e.split(" ",1),i=n.get(r);return t.ok(i,`Package not found in lockfile, "${e}"`),i}function de(e,t){return e.name<t.name?-1:e.name>t.name?1:0}const le={registry:{},flags:{}},fe={"vba-blocks":{index:"https://github.com/vba-blocks/registry",packages:"https://packages.vba-blocks.com"}},ge={};async function he(){const t={...le,...await me(e.env.config)||{}},n=await async function(){return}(e.env.cwd),r={...le,...n?await me(n):{}},i={},a={...fe,...t.registry,...r.registry,...i.registry},o={...ge,...t.flags,...r.flags,...i.flags},s={registry:{},git:new w,path:new T};for(const[e,{index:t,packages:n}]of Object.entries(a))s.registry[e]=new V({name:e,index:t,packages:n});return{registry:a,flags:o,sources:s}}async function me(t){const n=e.join(t,"config.toml");if(!await e.pathExists_1.pathExists(n))return{};const r=await e.readFile(n);return await b(r.toString())}async function ve(e,t){return{paths:{root:t,members:[]},root:e,members:[]}}const ye=e.env.debug("vbapm:project");exports.fetch=K,exports.fetchDependencies=async function(t){const n=await e.parallel(t.packages,async e=>{const n=await K(t.config.sources,e);return await M(n)},{progress:e.env.reporter.progress("Fetching dependencies")});return n},exports.init=async function(e){const{git:t}=await W();L(`init: ${e}`),await t.init({fs:o,dir:e})},exports.initProject=async function(t,n,r={}){n=e.normalize(n);const{type:i="project"}=r,a=await he(),o={type:i,name:t,version:"0.0.0",metadata:{authors:[],license:"UNLICENSED"},src:[],dependencies:[],references:[],devSrc:[],devDependencies:[],devReferences:[]},s=await ve(o,n);return{manifest:o,workspace:s,packages:[],config:a,paths:{root:s.paths.root,dir:n,build:e.join(n,"build"),backup:e.join(n,"build",".backup"),staging:await e.tmpFolder({dir:e.env.staging})},hasDirtyLockfile:!0}},exports.isRegistryDependency=f,exports.loadConfig=he,exports.loadProject=async function(t=e.env.cwd){const n=await M(t),r=await he(),i=await ve(n,t),a=await ie(i.paths.root),o=!a||!await async function(e,t){if(!e.metadata||"1"!==e.metadata.version)return!1;if(!await te(t.root,e.workspace.root))return!1;if(e.workspace.members.length!==t.members.length)return!1;const n={};t.members.forEach(e=>n[e.name]=e);for(const t of e.workspace.members){const e=n[t.name];if(!e)return!1;if(!await te(e,t))return!1}return!0}(a,i);return ye(o?"Resolving packages":"Loading packages from lockfile"),{manifest:n,workspace:i,packages:o?await ee(r,i,a?a.packages:[]):a.packages,config:r,paths:{root:i.paths.root,dir:t,build:e.join(t,"build"),backup:e.join(t,"build",".backup"),staging:await e.tmpFolder({dir:e.env.staging})},hasDirtyLockfile:o}},exports.loadWorkspace=ve,exports.parseManifest=N,exports.resolve=ee,exports.resolve$1=H,exports.toDependency=I,exports.unique=s,exports.unzip=J,exports.writeLockfile=async function(t,n){const r=e.join(t,"vbaproject.lock");re(`Writing lockfile to ${r}`);try{const i=function(e,t){const n=oe(e.workspace.root,e.packages,t),r=e.workspace.members.map(n=>oe(n,e.packages,t)),i=e.packages.sort(de).map(n=>{const{name:r,version:i,source:a}=n,o=n.dependencies.map(n=>ue(n,e.packages,t));return{name:r,version:i,source:se(a,t),dependencies:o}}),a=k({metadata:{version:"1"},root:n,members:r,packages:i});return`${a}`}(n,t);await e.writeFile(r,i)}catch(t){throw re("Error converting/writing"),re(t),new e.CliError(e.ErrorCode.LockfileWriteFailed,`Failed to write lockfile to "${r}".`)}},exports.writeManifest=async function(t,n){const r=function(t,n){const{type:r,name:i,version:a,metadata:{authors:o,publish:s,...c}}=t,u={name:i};a!==R&&(u.version=a);null!=o&&(u.authors=o);null!=s&&(u.publish=s);Object.assign(u,c);const p={[r]:u};t.target&&(p[r].target=function(t,n,r){let i,{name:a,type:o,path:s}=t;return s=e.relative(r,s),a!==n||"target"!==s?(i={type:o},a!==n&&(i.name=a),"target"!==s&&(i.path=s)):i=o,i}(t.target,t.name,n));p.src=q(t.src,n),t.dependencies.length&&(p.dependencies=m(t.dependencies,n));t.references.length&&(p.references=C(t.references));t.devSrc.length&&(p["dev-src"]=q(t.devSrc,n));t.devDependencies.length&&(p["dev-dependencies"]=m(t.devDependencies,n));t.devReferences.length&&(p["dev-references"]=C(t.devReferences));return p}(t,n),i=e.join(n,"vbaproject.toml");let a;if(await e.pathExists_1.pathExists(i)){const t=await e.readFile(i,"utf8");a=await async function(e,t){const{patch:n}=await Promise.resolve().then(function(){return require("./toml-patch.es-6bd2145d.js")});return n(e,t)}(t,r)}else a=await async function(e){const{stringify:t}=await Promise.resolve().then(function(){return require("./toml-patch.es-6bd2145d.js")});return t(e)}(r);await e.writeFile(i,a)},exports.zip=async function(e,t){const{create:n}=(await Promise.resolve().then(function(){return a(require("archiver"))})).default;return new Promise((r,a)=>{try{const o=i.createWriteStream(t),s=n("zip");o.on("close",()=>r()),o.on("error",a),s.pipe(o),s.on("error",a),s.directory(e,"/"),s.finalize()}catch(e){a(e)}})};
@@ -19,5 +19,5 @@ export declare class Resolver implements Iterable<ResolutionGraphEntry> {
19
19
  get(dependency: Dependency): Promise<Resolution>;
20
20
  getRegistration(id: string): Registration | undefined;
21
21
  prefer(preferred: DependencyGraph): void;
22
- [Symbol.iterator](): IterableIterator<[string, Resolution]>;
22
+ [Symbol.iterator](): MapIterator<[string, Resolution]>;
23
23
  }
@@ -0,0 +1 @@
1
+ "use strict";var r=require("./workbook-xml-5b96eac5.js"),e=require("./installer-2f42d28c.js"),i=require("./project-d784a14d.js");require("assert"),require("fs");var a=require("./get-target-cf4af796.js"),o=require("path");exports.runMacro=async function(t){let{target:n,file:s,macro:u,args:l=[""]}=t;if(!s){const r=await i.loadProject(),{target:o}=a.getTarget(r,n);s=e.join(r.paths.dir,"build",o.filename)}if(!s)throw new e.CliError(e.ErrorCode.RunMissingFile,"file is required for vbapm run (e.g. vbapm run --file FILE <macro> <arg>...).");if(!u)throw new e.CliError(e.ErrorCode.RunMissingMacro,"macro is required for vbapm run (e.g. vbapm run --file FILE <macro> <arg>...).");const c=r.extensionToApplication(o.extname(s)),f=await e.run(c,e.resolve(s),u,l),{stdout:g}=f;return g&&g.trim().length&&console.log(g),f};