@agoric/deploy-script-support 0.10.4-dev-d1a4a53.0 → 0.10.4-dev-872bb3b.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/package.json +12 -12
- package/src/externalTypes.js +1 -1
- package/src/extract-proposal.js +60 -44
- package/src/getBundlerMaker.js +3 -0
- package/src/writeCoreProposal.js +39 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/deploy-script-support",
|
|
3
|
-
"version": "0.10.4-dev-
|
|
3
|
+
"version": "0.10.4-dev-872bb3b.0+872bb3b",
|
|
4
4
|
"description": "Helpers and other support for writing deploy scripts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/helpers.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"test:xs": "exit 0",
|
|
14
14
|
"lint-fix": "yarn lint:eslint --fix",
|
|
15
15
|
"lint:eslint": "eslint .",
|
|
16
|
-
"lint:types": "tsc
|
|
16
|
+
"lint:types": "tsc",
|
|
17
17
|
"lint": "run-s --continue-on-error lint:*"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@agoric/assert": "0.6.1-dev-
|
|
38
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
39
|
-
"@agoric/import-manager": "0.3.12-dev-
|
|
40
|
-
"@agoric/internal": "0.3.3-dev-
|
|
41
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
42
|
-
"@agoric/store": "0.9.3-dev-
|
|
43
|
-
"@agoric/time": "0.3.3-dev-
|
|
44
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
37
|
+
"@agoric/assert": "0.6.1-dev-872bb3b.0+872bb3b",
|
|
38
|
+
"@agoric/ertp": "0.16.3-dev-872bb3b.0+872bb3b",
|
|
39
|
+
"@agoric/import-manager": "0.3.12-dev-872bb3b.0+872bb3b",
|
|
40
|
+
"@agoric/internal": "0.3.3-dev-872bb3b.0+872bb3b",
|
|
41
|
+
"@agoric/notifier": "0.6.3-dev-872bb3b.0+872bb3b",
|
|
42
|
+
"@agoric/store": "0.9.3-dev-872bb3b.0+872bb3b",
|
|
43
|
+
"@agoric/time": "0.3.3-dev-872bb3b.0+872bb3b",
|
|
44
|
+
"@agoric/zoe": "0.26.3-dev-872bb3b.0+872bb3b",
|
|
45
45
|
"@endo/base64": "^0.2.32",
|
|
46
46
|
"@endo/bundle-source": "^2.5.2",
|
|
47
47
|
"@endo/far": "^0.2.19",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@endo/zip": "^0.2.32"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@agoric/vats": "0.15.2-dev-
|
|
54
|
+
"@agoric/vats": "0.15.2-dev-872bb3b.0+872bb3b",
|
|
55
55
|
"@endo/init": "^0.5.57",
|
|
56
56
|
"ava": "^5.3.0",
|
|
57
57
|
"import-meta-resolve": "^2.2.1"
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "872bb3be25122001190a35d0155d942315c81238"
|
|
73
73
|
}
|
package/src/externalTypes.js
CHANGED
package/src/extract-proposal.js
CHANGED
|
@@ -40,6 +40,19 @@ const findModule = (initDir, srcSpec) =>
|
|
|
40
40
|
? pathResolve(initDir, srcSpec)
|
|
41
41
|
: req.resolve(srcSpec);
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* @param {{ bundleID?: string, bundleName?: string }} handle - mutated then hardened
|
|
45
|
+
* @param {string} sourceSpec - the specifier of a module to load
|
|
46
|
+
* @param {number} sequence - the sequence number of the proposal
|
|
47
|
+
* @param {string} piece - the piece of the proposal
|
|
48
|
+
* @returns {Promise<[string, any]>}
|
|
49
|
+
*/
|
|
50
|
+
const namedHandleToBundleSpec = async (handle, sourceSpec, sequence, piece) => {
|
|
51
|
+
handle.bundleName = `coreProposal${sequence}_${piece}`;
|
|
52
|
+
harden(handle);
|
|
53
|
+
return harden([handle.bundleName, { sourceSpec }]);
|
|
54
|
+
};
|
|
55
|
+
|
|
43
56
|
/**
|
|
44
57
|
* Format core proposals to be run at bootstrap:
|
|
45
58
|
* SwingSet `bundles` configuration
|
|
@@ -54,26 +67,28 @@ const findModule = (initDir, srcSpec) =>
|
|
|
54
67
|
* @param {ConfigProposal[]} coreProposals - governance
|
|
55
68
|
* proposals to run at chain bootstrap for scenarios such as sim-chain.
|
|
56
69
|
* @param {FilePath} [dirname]
|
|
57
|
-
* @param {
|
|
58
|
-
* @param {
|
|
70
|
+
* @param {object} [opts]
|
|
71
|
+
* @param {typeof makeEnactCoreProposalsFromBundleRef} [opts.makeEnactCoreProposals]
|
|
72
|
+
* @param {(i: number) => number} [opts.getSequenceForProposal]
|
|
73
|
+
* @param {typeof namedHandleToBundleSpec} [opts.handleToBundleSpec]
|
|
59
74
|
*/
|
|
60
75
|
export const extractCoreProposalBundles = async (
|
|
61
76
|
coreProposals,
|
|
62
77
|
dirname = '.',
|
|
63
|
-
|
|
64
|
-
getSequenceForProposal,
|
|
78
|
+
opts,
|
|
65
79
|
) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
getSequenceForProposal = i => i
|
|
69
|
-
|
|
80
|
+
const {
|
|
81
|
+
makeEnactCoreProposals = makeEnactCoreProposalsFromBundleRef,
|
|
82
|
+
getSequenceForProposal = i => i,
|
|
83
|
+
handleToBundleSpec = namedHandleToBundleSpec,
|
|
84
|
+
} = opts || {};
|
|
70
85
|
|
|
71
86
|
dirname = pathResolve(dirname);
|
|
72
87
|
dirname = await fs.promises
|
|
73
88
|
.stat(dirname)
|
|
74
89
|
.then(stbuf => (stbuf.isDirectory() ? dirname : path.dirname(dirname)));
|
|
75
90
|
|
|
76
|
-
/** @type {Map<{ bundleName?: string }, { source: string, bundle?: string }>} */
|
|
91
|
+
/** @type {Map<{ bundleID?: string, bundleName?: string }, { source: string, bundle?: string }>} */
|
|
77
92
|
const bundleHandleToAbsolutePaths = new Map();
|
|
78
93
|
|
|
79
94
|
const bundleToSource = new Map();
|
|
@@ -151,29 +166,30 @@ export const extractCoreProposalBundles = async (
|
|
|
151
166
|
);
|
|
152
167
|
|
|
153
168
|
// Add the proposal bundle handles in sorted order.
|
|
154
|
-
const bundleSpecEntries =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
169
|
+
const bundleSpecEntries = await Promise.all(
|
|
170
|
+
[...thisProposalBundleHandles.keys()]
|
|
171
|
+
.map(handle => [handle, bundleHandleToAbsolutePaths.get(handle)])
|
|
172
|
+
.sort(([_hnda, { source: a }], [_hndb, { source: b }]) => {
|
|
173
|
+
if (a < b) {
|
|
174
|
+
return -1;
|
|
175
|
+
}
|
|
176
|
+
if (a > b) {
|
|
177
|
+
return 1;
|
|
178
|
+
}
|
|
179
|
+
return 0;
|
|
180
|
+
})
|
|
181
|
+
.map(async ([handle, absolutePaths], j) => {
|
|
182
|
+
// Transform the bundle handle identity into a bundleName reference.
|
|
183
|
+
const specEntry = await handleToBundleSpec(
|
|
184
|
+
handle,
|
|
185
|
+
absolutePaths.source,
|
|
186
|
+
thisProposalSequence,
|
|
187
|
+
String(j),
|
|
188
|
+
);
|
|
189
|
+
harden(handle);
|
|
190
|
+
return specEntry;
|
|
191
|
+
}),
|
|
192
|
+
);
|
|
177
193
|
|
|
178
194
|
// Now that we've assigned all the bundleNames and hardened the
|
|
179
195
|
// handles, we can extract the behavior bundle.
|
|
@@ -192,21 +208,21 @@ export const extractCoreProposalBundles = async (
|
|
|
192
208
|
exportedGetManifest
|
|
193
209
|
](harden({ restoreRef: () => null }), ...manifestArgs);
|
|
194
210
|
|
|
195
|
-
const behaviorBundleHandle =
|
|
196
|
-
|
|
197
|
-
});
|
|
198
|
-
const behaviorAbsolutePaths = harden({
|
|
199
|
-
source: behaviorSource,
|
|
200
|
-
});
|
|
201
|
-
bundleHandleToAbsolutePaths.set(
|
|
211
|
+
const behaviorBundleHandle = {};
|
|
212
|
+
const specEntry = await handleToBundleSpec(
|
|
202
213
|
behaviorBundleHandle,
|
|
203
|
-
|
|
214
|
+
behaviorSource,
|
|
215
|
+
thisProposalSequence,
|
|
216
|
+
'behaviors',
|
|
204
217
|
);
|
|
218
|
+
bundleSpecEntries.unshift(specEntry);
|
|
205
219
|
|
|
206
|
-
|
|
207
|
-
behaviorBundleHandle
|
|
208
|
-
{
|
|
209
|
-
|
|
220
|
+
bundleHandleToAbsolutePaths.set(
|
|
221
|
+
behaviorBundleHandle,
|
|
222
|
+
harden({
|
|
223
|
+
source: behaviorSource,
|
|
224
|
+
}),
|
|
225
|
+
);
|
|
210
226
|
|
|
211
227
|
return harden({
|
|
212
228
|
ref: behaviorBundleHandle,
|
package/src/getBundlerMaker.js
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
import { E } from '@endo/far';
|
|
14
14
|
import url from 'url';
|
|
15
15
|
|
|
16
|
+
/** @typedef {ReturnType<import('./endo-pieces-contract.js')['start']>['publicFacet']} BundleMaker */
|
|
17
|
+
|
|
16
18
|
export const makeGetBundlerMaker =
|
|
17
19
|
(homeP, { lookup, bundleSource }) =>
|
|
18
20
|
async ({
|
|
@@ -20,6 +22,7 @@ export const makeGetBundlerMaker =
|
|
|
20
22
|
log = console.log,
|
|
21
23
|
} = {}) => {
|
|
22
24
|
const { board: optionalBoard, zoe, scratch } = await homeP;
|
|
25
|
+
/** @type {() => Promise<BundleMaker>} */
|
|
23
26
|
const lookupOrCreate = async () => {
|
|
24
27
|
// Locate the bundler maker if any already exists at the given path.
|
|
25
28
|
let bundlerMaker = await lookup(JSON.parse(BUNDLER_MAKER_LOOKUP));
|
package/src/writeCoreProposal.js
CHANGED
|
@@ -7,6 +7,25 @@ import { createBundles } from '@agoric/internal/src/node/createBundles.js';
|
|
|
7
7
|
import { defangAndTrim, mergePermits, stringify } from './code-gen.js';
|
|
8
8
|
import { makeCoreProposalBehavior, permits } from './coreProposalBehavior.js';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @callback WriteCoreProposal
|
|
12
|
+
* @param {string} filePrefix
|
|
13
|
+
* @param {import('./externalTypes.js').ProposalBuilder} proposalBuilder
|
|
14
|
+
* @returns {Promise<void>}
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param {*} homeP
|
|
20
|
+
* @param {*} endowments
|
|
21
|
+
* @param {{
|
|
22
|
+
* getBundlerMaker: () => Promise<import('./getBundlerMaker.js').BundleMaker>,
|
|
23
|
+
* getBundleSpec: (...args: *) => Promise<import('./externalTypes.js').ManifestBundleRef>,
|
|
24
|
+
* log?: typeof console.log,
|
|
25
|
+
* writeFile?: typeof fs.promises.writeFile
|
|
26
|
+
* }} io
|
|
27
|
+
* @returns {WriteCoreProposal}
|
|
28
|
+
*/
|
|
10
29
|
export const makeWriteCoreProposal = (
|
|
11
30
|
homeP,
|
|
12
31
|
endowments,
|
|
@@ -50,8 +69,18 @@ export const makeWriteCoreProposal = (
|
|
|
50
69
|
};
|
|
51
70
|
};
|
|
52
71
|
|
|
53
|
-
let mutex =
|
|
72
|
+
let mutex =
|
|
73
|
+
/** @type {Promise<import('./externalTypes.js').ManifestBundleRef | undefined>} */ (
|
|
74
|
+
Promise.resolve()
|
|
75
|
+
);
|
|
76
|
+
/** @type {WriteCoreProposal} */
|
|
54
77
|
const writeCoreProposal = async (filePrefix, proposalBuilder) => {
|
|
78
|
+
/**
|
|
79
|
+
*
|
|
80
|
+
* @param {string} entrypoint
|
|
81
|
+
* @param {string} [bundlePath]
|
|
82
|
+
* @returns {Promise<NodeModule>}
|
|
83
|
+
*/
|
|
55
84
|
const getBundle = async (entrypoint, bundlePath) => {
|
|
56
85
|
if (!bundlePath) {
|
|
57
86
|
return bundleSource(pathResolve(entrypoint));
|
|
@@ -62,7 +91,14 @@ export const makeWriteCoreProposal = (
|
|
|
62
91
|
return ns.default;
|
|
63
92
|
};
|
|
64
93
|
|
|
65
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Install an entrypoint.
|
|
96
|
+
*
|
|
97
|
+
* @param {string} entrypoint
|
|
98
|
+
* @param {string} [bundlePath]
|
|
99
|
+
* @param [opts]
|
|
100
|
+
* @returns {Promise<import('./externalTypes.js').ManifestBundleRef>}
|
|
101
|
+
*/
|
|
66
102
|
const install = async (entrypoint, bundlePath, opts) => {
|
|
67
103
|
const bundle = getBundle(entrypoint, bundlePath);
|
|
68
104
|
|
|
@@ -71,6 +107,7 @@ export const makeWriteCoreProposal = (
|
|
|
71
107
|
// console.log('installing', { filePrefix, entrypoint, bundlePath });
|
|
72
108
|
return getBundleSpec(bundle, getBundler, opts);
|
|
73
109
|
});
|
|
110
|
+
// @ts-expect-error xxx mutex type narrowing
|
|
74
111
|
return mutex;
|
|
75
112
|
};
|
|
76
113
|
|