update publish script
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"module": "index.ts",
|
"module": "index.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"build": "rm -rf dist && tsup",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"format": "prettier --check \"**/*.{mjs,ts,md,json}\"",
|
"format": "prettier --check \"**/*.{mjs,ts,md,json}\"",
|
||||||
"typecheck": "tsc --noEmit"
|
"typecheck": "tsc --noEmit"
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ import fs from 'node:fs';
|
|||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
|
|
||||||
import sdkPkg from '../../packages/sdk/package.json';
|
|
||||||
import typesPkg from '../../packages/types/package.json';
|
import typesPkg from '../../packages/types/package.json';
|
||||||
|
|
||||||
|
const sdkPackages = ['sdk', 'sdk-native', 'sdk-web'];
|
||||||
|
// const sdkPackages = ['sdk'];
|
||||||
|
|
||||||
const workspacePath = (relativePath: string) =>
|
const workspacePath = (relativePath: string) =>
|
||||||
path.resolve(__dirname, '../../', relativePath);
|
path.resolve(__dirname, '../../', relativePath);
|
||||||
|
|
||||||
@@ -50,10 +52,12 @@ function main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
savePackageJson(workspacePath('./packages/sdk/package.json'), {
|
for (const name of sdkPackages) {
|
||||||
...sdkPkg,
|
const pkgJson = require(workspacePath(`./packages/${name}/package.json`));
|
||||||
|
savePackageJson(workspacePath(`./packages/${name}/package.json`), {
|
||||||
|
...pkgJson,
|
||||||
...properties,
|
...properties,
|
||||||
dependencies: Object.entries(sdkPkg.dependencies).reduce(
|
dependencies: Object.entries(pkgJson.dependencies).reduce(
|
||||||
(acc, [depName, depVersion]) => ({
|
(acc, [depName, depVersion]) => ({
|
||||||
...acc,
|
...acc,
|
||||||
[depName]: depName.startsWith('@mixan') ? version : depVersion,
|
[depName]: depName.startsWith('@mixan') ? version : depVersion,
|
||||||
@@ -61,6 +65,7 @@ function main() {
|
|||||||
{}
|
{}
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
savePackageJson(workspacePath('./packages/types/package.json'), {
|
savePackageJson(workspacePath('./packages/types/package.json'), {
|
||||||
...typesPkg,
|
...typesPkg,
|
||||||
@@ -73,11 +78,13 @@ function main() {
|
|||||||
console.log('✅ Update JSON files');
|
console.log('✅ Update JSON files');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
execSync('pnpm dlx tsup', {
|
for (const name of sdkPackages) {
|
||||||
cwd: workspacePath('./packages/sdk'),
|
execSync('pnpm build', {
|
||||||
|
cwd: workspacePath(`./packages/${name}`),
|
||||||
});
|
});
|
||||||
execSync('pnpm dlx tsup', {
|
}
|
||||||
cwd: workspacePath('./packages/types'),
|
execSync('pnpm build', {
|
||||||
|
cwd: workspacePath(`./packages/types`),
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
exit('Failed build packages', error);
|
exit('Failed build packages', error);
|
||||||
@@ -86,9 +93,11 @@ function main() {
|
|||||||
console.log('✅ Built packages');
|
console.log('✅ Built packages');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
for (const name of sdkPackages) {
|
||||||
execSync('npm publish --access=public', {
|
execSync('npm publish --access=public', {
|
||||||
cwd: workspacePath('./packages/sdk'),
|
cwd: workspacePath(`./packages/${name}`),
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
execSync('npm publish --access=public', {
|
execSync('npm publish --access=public', {
|
||||||
cwd: workspacePath('./packages/types'),
|
cwd: workspacePath('./packages/types'),
|
||||||
|
|||||||
Reference in New Issue
Block a user