Skip to content

Commit b37e08f

Browse files
committed
feat: publish lit actions code to ipfs automatically before publishing packages to npm
1 parent 7c60ecf commit b37e08f

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

packages/wrapped-keys-lit-actions/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"genReact": false
2525
},
2626
"scripts": {
27-
"generate-lit-actions": "yarn node ./esbuild.config.js"
27+
"generate-lit-actions": "yarn node ./esbuild.config.js",
28+
"publish-lit-actions": "yarn node ./sync-actions-to-ipfs"
2829
},
2930
"version": "6.10.0",
3031
"main": "./dist/src/index.js",

tools/scripts/pub.mjs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
redLog,
1313
question,
1414
writeJsonFile,
15-
yellowLog,
1615
} from './utils.mjs';
1716

1817
const args = getArgs();
@@ -101,8 +100,23 @@ await question('Are you sure you want to publish to? (y/n)', {
101100
// await 1 second
102101
await new Promise((resolve) => setTimeout(resolve, 1000));
103102

103+
// first publish the wrapped keys lit actions by running yarn publish-lit-actions in ./packages/wrapped-keys-lit-actions
104+
await spawnCommand(
105+
'dotenvx',
106+
['run', '-f', '../../.env', '--', 'yarn', 'publish-lit-actions'],
107+
{
108+
cwd: './packages/wrapped-keys-lit-actions',
109+
},
110+
{
111+
logExit: false,
112+
}
113+
);
114+
104115
let counter = 0;
105116

117+
// await 10 seconds to ipfs getting updated
118+
await new Promise((resolve) => setTimeout(resolve, 10*1000));
119+
106120
await asyncForEach(dirs, async (dir) => {
107121
// read the package.json file
108122
const pkg = await readJsonFile(`${dir}/package.json`);
@@ -178,7 +192,7 @@ await question('Are you sure you want to publish to? (y/n)', {
178192
});
179193

180194
while (true) {
181-
// wait for 1 second
195+
// wait a few secs to check again if all packages are published
182196
await new Promise((resolve) => setTimeout(resolve, 2000));
183197
if (counter >= dirs.length) {
184198
greenLog('🎉 Publish complete!', true);

tools/scripts/utils.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export const spawnCommand = (
185185
if (options2.logExit) {
186186
console.log(`child process exited with code ${code}`);
187187
}
188-
options2.exitCallback(code);
188+
options2.exitCallback?.(code);
189189
});
190190
};
191191

0 commit comments

Comments
 (0)