Skip to content

Commit d3e3af1

Browse files
committed
build: restore api to api.3
1 parent 8d842fc commit d3e3af1

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,8 @@
2525
"scripts": {
2626
"prebuild": "rimraf dist",
2727
"build": "node scripts/build.js",
28-
"build2": "node scripts/build-2.js",
29-
"build3": "node scripts/build-3.js",
28+
"build:vue2": "yarn build --version=2",
3029
"release": "node scripts/publish.js",
31-
"old:build": "rollup -c rollup.config.js",
32-
"old:start": "rollup -c rollup.config.js -w",
3330
"test": "jest --coverage",
3431
"test:watch": "jest --coverage --watch",
3532
"test:prod": "npm run lint && npm run test -- --no-cache",

scripts/build.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ async function build(target, targetVersion) {
4444
const pkgDir = path.resolve(`packages/${target}`);
4545
const pkg = require(`${pkgDir}/package.json`);
4646
const renameRestore = await apiRename(target, targetVersion);
47+
let packageRestore = () =>
48+
fs.writeJSON(`${pkgDir}/package.json`, pkg, { spaces: 2 });
49+
4750
try {
4851
// only build published packages for release
4952
if (isRelease && pkg.private) {
@@ -67,8 +70,6 @@ async function build(target, targetVersion) {
6770
}
6871
: pkg.dependencies;
6972

70-
pkg.dependencies = dependencies;
71-
7273
const newPkg = {
7374
...pkg,
7475
dependencies,
@@ -101,15 +102,17 @@ async function build(target, targetVersion) {
101102
`TARGET:${target}`,
102103
formats ? `FORMATS:${formats}` : ``,
103104
buildTypes ? `TYPES:true` : ``,
104-
prodOnly ? `PROD_ONLY:true` : ``,
105-
lean ? `LEAN:true` : ``
105+
prodOnly ? `PROD_ONLY:true` : ``
106106
]
107107
.filter(Boolean)
108108
.join(",")
109109
],
110110
{ stdio: "inherit" }
111111
);
112112
} catch (e) {
113+
await renameRestore();
114+
await packageRestore();
115+
113116
return process.exit(1);
114117
}
115118

@@ -154,6 +157,8 @@ async function build(target, targetVersion) {
154157
`API Extractor completed with ${extractorResult.errorCount} errors` +
155158
` and ${extractorResult.warningCount} warnings`
156159
);
160+
await renameRestore();
161+
await packageRestore();
157162
process.exitCode = 1;
158163
}
159164

@@ -162,6 +167,7 @@ async function build(target, targetVersion) {
162167
} finally {
163168
// await restorePkg();
164169
await renameRestore();
170+
await packageRestore();
165171
}
166172
}
167173

@@ -200,18 +206,18 @@ async function apiRename(target, targetVersion) {
200206
assert([2, 3].includes(targetVersion));
201207

202208
const pkgDir = path.resolve(`packages/${target}`);
203-
await fs.rename(`${pkgDir}/src/api.ts`, `${pkgDir}/src/api.N.ts`);
204-
await fs.rename(
209+
// await fs.rename(`${pkgDir}/src/api.ts`, `${pkgDir}/src/api.N.ts`);
210+
await fs.copy(
205211
`${pkgDir}/src/api.${targetVersion}.ts`,
206-
`${pkgDir}/src/api.ts`
212+
`${pkgDir}/src/api.ts`,
213+
{ overwrite: true }
207214
);
208215

209216
const restore = async () => {
210-
await fs.rename(
211-
`${pkgDir}/src/api.ts`,
212-
`${pkgDir}/src/api.${targetVersion}.ts`
213-
);
214-
await fs.rename(`${pkgDir}/src/api.N.ts`, `${pkgDir}/src/api.ts`);
217+
await fs.copy(`${pkgDir}/src/api.3.ts`, `${pkgDir}/src/api.ts`, {
218+
overwrite: true
219+
});
220+
// await fs.rename(`${pkgDir}/src/api.N.ts`, `${pkgDir}/src/api.ts`);
215221
};
216222

217223
return restore;

0 commit comments

Comments
 (0)