Skip to content

Commit

Permalink
1.0.75-2
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyuang committed May 9, 2024
1 parent 02ae8b9 commit 490dbde
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
3 changes: 0 additions & 3 deletions package.json
Expand Up @@ -51,11 +51,8 @@
"build:c": "node scripts/compile.js",
"build:dev": "env=development node scripts/build.js",
"build": "node scripts/build.js",
"build:debug": "napi build --platform",
"publish:npm": "node scripts/publish.js",
"test": "esno ./test.ts",
"universal": "napi universal",
"version": "napi version",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add . && git commit -m \"docs: update changelog.md\" && git push origin master",
"pub": "npm version patch && git push origin master --tags && npm run changelog"
},
Expand Down
32 changes: 14 additions & 18 deletions scripts/publish.js
Expand Up @@ -5,37 +5,32 @@ const { execSync } = require('child_process');

const myResolve = dir => resolve(process.cwd(), dir);
const pkg = require(resolve(process.cwd(), './package.json'))
const { version, optionalDependencies } = pkg
for (const key in optionalDependencies) {
optionalDependencies[key] = version
}
console.log('yuuang', pkg)
writeFileSync(resolve(process.cwd(), './package.json'), JSON.stringify(pkg, null, 2))
const { version } = pkg

const isPreReleaseVersion = () => {
const preReleaseRegex = /-\w+/;
return preReleaseRegex.test(version);
};

const publishPackage = (path) => {
const pkgPath = resolve(path, 'package.json');
const pkgJson = require(pkgPath);
const { version } = pkgJson;
const tag = isPreReleaseVersion(version) ? `--tag alpha` : '';
const tag = isPreReleaseVersion() ? `--tag alpha` : '';
execSync(`npm publish ${tag}`, { cwd: path, stdio: 'inherit' });
};

const optionalDependencies = {}
const publishSubpackages = async () => {
const folders = await fsPromises.readdir(myResolve('./npm'));
for (const item of folders) {
if (item !== '.DS_Store') {
cp(myResolve('./README.md'), myResolve(`./npm/${item}`));
const p = require(myResolve(`./npm/${item}/package.json`))
p.version = version
writeFileSync(myResolve(`./npm/${item}/package.json`), JSON.stringify(p, null, 2))
optionalDependencies[p.name] = version
await fsPromises.writeFile(myResolve(`./npm/${item}/package.json`), JSON.stringify(p, null, 2))
publishPackage(myResolve(`./npm/${item}`), item);
}
}
await fsPromises.writeFile(resolve(process.cwd(), './package.json'), JSON.stringify(pkg, null, 2))
console.log('yuuang', pkg)
};

const publishRoot = async () => {
Expand All @@ -46,12 +41,13 @@ const publishRoot = async () => {
publishPackage(rootPath);
};

Promise.all([
publishSubpackages(),
publishRoot()
]).then(() => {
console.log('Publish succeeded');
})
publishSubpackages().then(async () => {
await publishRoot()
}).
then(() => {
console.log('Publish succeeded');
})
.catch(err => {
console.error(`Publish failed: ${err}`);
procee.exit(1)
});

0 comments on commit 490dbde

Please sign in to comment.