Skip to content

Commit

Permalink
Merge pull request #1080 from momentum-xyz/feat/plugins/creator
Browse files Browse the repository at this point in the history
fix(plugin): generate plugin tarball without removing ./build dir
  • Loading branch information
dmitry-yudakov authored Oct 25, 2023
2 parents c0017d2 + 3ae0f06 commit 9908b92
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/sdk/bin/momentum-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const DEFAULT_PORT = 3001;

const args = process.argv.slice(2);
const scriptIndex = args.findIndex(
(x) => x === 'build' || x === 'start' || x === 'test' || x === 'start:plugin'
(x) => x === 'build' || x === 'pack' || x === 'start' || x === 'test' || x === 'start:plugin'
);
const script = scriptIndex === -1 ? args[0] : args[scriptIndex];

Expand Down Expand Up @@ -41,6 +41,8 @@ switch (script) {
spawnProcess('craco', processArgs, env);
break;
}
case 'pack':
break;
default:
console.log(`Unknown script "${script}".`);
console.log('Perhaps you need to update @momentum-xyz/sdk?');
Expand All @@ -49,6 +51,7 @@ switch (script) {

switch (script) {
case 'build':
case 'pack':
generateAndStoreManifest();
break;
default:
Expand Down Expand Up @@ -109,9 +112,17 @@ function generateAndStoreManifest() {

const versionedDir = `./${name}-${version}`;

fs.renameSync(BUILD_DIR, versionedDir);
console.log('[momentum-plugin] Plugin build stored in', BUILD_DIR);
console.log('[momentum-plugin] Temp copy plugin build to', versionedDir);
fs.cpSync(BUILD_DIR, versionedDir, {
force: true,
preserveTimestamps: true,
recursive: true
});

console.log('[momentum-plugin] Compress plugin build to', `${versionedDir}.tar.gz`);
spawnProcess('tar', ['-czf', `${versionedDir}.tar.gz`, versionedDir], {});
console.log('[momentum-plugin] Plugin tarball generated: ', `${versionedDir}.tar.gz`);

console.log('[momentum-plugin] Removing temp dir', versionedDir);
fs.rmSync(versionedDir, {recursive: true});
}

0 comments on commit 9908b92

Please sign in to comment.