Skip to content

Commit

Permalink
feat: update release script
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondYuan committed Jul 3, 2021
1 parent b9405b5 commit 0774826
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 73 deletions.
73 changes: 0 additions & 73 deletions script/ci.js

This file was deleted.

9 changes: 9 additions & 0 deletions script/release.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { getBuildOptions } from './utils/get-build-options';
import { TDistType, IReleaseProcessEnv } from './utils/types';
import { build } from './utils/build';
import { pack } from './utils/pack';
import path from 'path';
import fs from 'fs';

const { isBeta } = require('../webpack/utils/manifest');

(async () => {
const releaseDir = path.join(__dirname, '../release');
const distDir = path.join(__dirname, '../dist');
if (!fs.existsSync(releaseDir)) {
fs.mkdirSync(releaseDir);
}
const buildEnv = (process.env as unknown) as IReleaseProcessEnv;
const buildOptions = getBuildOptions(buildEnv);
const CurrentDistType: TDistType = isBeta() ? 'Beta' : 'Release';
Expand All @@ -15,5 +23,6 @@ const { isBeta } = require('../webpack/utils/manifest');
for (const iterator of buildOptions.targetBrowser) {
console.log(`Release: ${iterator} PublishToStore: ${buildOptions.publishToStore}`);
await build({ targetBrowser: iterator, publishToStore: buildOptions.publishToStore });
await pack({ targetBrowser: iterator, releaseDir, distDir });
}
})();
26 changes: 26 additions & 0 deletions script/utils/pack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import path from 'path';
import { TBuildTarget } from './types';
import compressing from 'compressing';
import fs from 'fs';
const pump = require('pump');
interface IPackOptions {
distDir: string;
releaseDir: string;
targetBrowser: TBuildTarget;
}

export function pack(options: IPackOptions) {
const zipStream = new compressing.zip.Stream();
const files = fs.readdirSync(options.distDir).filter(p => !p.match(/^\./));
for (const file of files) {
zipStream.addEntry(path.join(options.distDir, file));
}
const dest = path.join(
options.releaseDir,
`web_clipper_${options.targetBrowser.toLocaleLowerCase()}.zip`
);
const destStream = fs.createWriteStream(dest);
return new Promise(r => {
pump(zipStream, destStream, r);
});
}

0 comments on commit 0774826

Please sign in to comment.