Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev v0.4 #218

Merged
merged 4 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Publish Package to npmjs
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- run: npm run test
- run: npm run build
- run: cd packages/types/
- run: npm publish --tag next
- run: cd ../util/
- run: npm publish --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "root",
"private": false,
"version": "0.4.0-alpha.1",
"scripts": {
"postinstall": "npm run build",
"dev": "vite-node ./scripts/dev.ts",
Expand All @@ -23,7 +23,8 @@
"prepush": "npm run lint",
"clear:jest": "rm -rf ./packages/*/__tests__/__snapshots__",
"pu": "pnpm i && npm run build && lerna publish --force-publish",
"pu2": "lerna version && npm run build && lerna publish from-git --force-publish"
"pu2": "lerna version && npm run build && lerna publish from-git --force-publish",
"upgrade:version": "vite-node ./scripts/upgrade-version.ts && pnpm i"
},
"devDependencies": {
"@babel/core": "^7.22.19",
Expand Down
8 changes: 4 additions & 4 deletions packages/board/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@idraw/board",
"version": "0.4.0-alpha.0",
"version": "0.4.0-alpha.1",
"description": "",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand All @@ -24,11 +24,11 @@
"@idraw/types": "^0.4.0-alpha.0"
},
"dependencies": {
"@idraw/util": "^0.4.0-alpha.0",
"@idraw/renderer": "^0.4.0-alpha.0"
"@idraw/util": "^0.4.0-alpha.1",
"@idraw/renderer": "^0.4.0-alpha.1"
},
"publishConfig": {
"access": "public"
},
"gitHead": "5cc462b9206ea0e4e70b5183771dfbf694402483"
}
}
10 changes: 5 additions & 5 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@idraw/core",
"version": "0.4.0-alpha.0",
"version": "0.4.0-alpha.1",
"description": "",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand All @@ -24,12 +24,12 @@
"@idraw/types": "^0.4.0-alpha.0"
},
"dependencies": {
"@idraw/board": "^0.4.0-alpha.0",
"@idraw/renderer": "^0.4.0-alpha.0",
"@idraw/util": "^0.4.0-alpha.0"
"@idraw/board": "^0.4.0-alpha.1",
"@idraw/renderer": "^0.4.0-alpha.1",
"@idraw/util": "^0.4.0-alpha.1"
},
"publishConfig": {
"access": "public"
},
"gitHead": "5cc462b9206ea0e4e70b5183771dfbf694402483"
}
}
8 changes: 4 additions & 4 deletions packages/idraw/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "idraw",
"version": "0.4.0-alpha.0",
"version": "0.4.0-alpha.1",
"description": "",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand All @@ -24,11 +24,11 @@
"@idraw/types": "^0.4.0-alpha.0"
},
"dependencies": {
"@idraw/core": "^0.4.0-alpha.0",
"@idraw/util": "^0.4.0-alpha.0"
"@idraw/core": "^0.4.0-alpha.1",
"@idraw/util": "^0.4.0-alpha.1"
},
"publishConfig": {
"access": "public"
},
"gitHead": "5cc462b9206ea0e4e70b5183771dfbf694402483"
}
}
8 changes: 4 additions & 4 deletions packages/lab/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@idraw/lab",
"version": "0.4.0-alpha.0",
"version": "0.4.0-alpha.1",
"dependencies": {
"@ant-design/icons": "^5.1.3",
"@idraw/core": "^0.4.0-alpha.0",
"@idraw/util": "^0.4.0-alpha.0",
"@idraw/core": "^0.4.0-alpha.1",
"@idraw/util": "^0.4.0-alpha.1",
"antd": "^5.5.0",
"classnames": "^2.3.2",
"react": "^18.2.0",
Expand All @@ -15,4 +15,4 @@
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.1"
}
}
}
6 changes: 3 additions & 3 deletions packages/renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@idraw/renderer",
"version": "0.4.0-alpha.0",
"version": "0.4.0-alpha.1",
"description": "",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand All @@ -24,10 +24,10 @@
"@idraw/types": "^0.4.0-alpha.0"
},
"dependencies": {
"@idraw/util": "^0.4.0-alpha.0"
"@idraw/util": "^0.4.0-alpha.1"
},
"publishConfig": {
"access": "public"
},
"gitHead": "5cc462b9206ea0e4e70b5183771dfbf694402483"
}
}
4 changes: 2 additions & 2 deletions packages/types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@idraw/types",
"version": "0.4.0-alpha.0",
"version": "0.4.0-alpha.1",
"description": "",
"main": "src/index.ts",
"types": "src/index.ts",
Expand All @@ -23,4 +23,4 @@
"access": "public"
},
"gitHead": "5cc462b9206ea0e4e70b5183771dfbf694402483"
}
}
4 changes: 2 additions & 2 deletions packages/util/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@idraw/util",
"version": "0.4.0-alpha.0",
"version": "0.4.0-alpha.1",
"description": "",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand All @@ -27,4 +27,4 @@
"access": "public"
},
"gitHead": "5cc462b9206ea0e4e70b5183771dfbf694402483"
}
}
20 changes: 10 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions scripts/upgrade-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { readJSONFile, writeJSONFile } from './util/file';
import { getRootPackageJSON, getAllSubPackageDirs } from './util/project';
const pkg = getRootPackageJSON();
const version = pkg.version;
async function run() {
const pkgDirs = getAllSubPackageDirs();
const allPkgMap: Record<string, { file: string; json: any }> = {};
pkgDirs.forEach((dir) => {
const file = ['packages', dir, 'package.json'].join('/');
const json = readJSONFile('packages', dir, 'package.json');
allPkgMap[json.name] = { file, json };
});
for (const key in allPkgMap) {
if (allPkgMap.hasOwnProperty(key)) {
console.log(`Upgrade [${key}] from ${allPkgMap[key].json.version} to ${version}`);
allPkgMap[key].json.version = version;
if (allPkgMap[key]?.json?.dependencies) {
for (const depName in allPkgMap[key].json.dependencies) {
if (allPkgMap.hasOwnProperty(depName)) {
allPkgMap[key].json.dependencies[depName] = `^${version}`;
}
}
}
}
writeJSONFile(allPkgMap[key].file, allPkgMap[key].json);
}
}

run()
.then(() => {
console.log(`[@idraw]: Upgrade all packages version ${version} success!`);
})
.catch((err) => {
console.error(err);
throw err;
});
23 changes: 20 additions & 3 deletions scripts/util/file.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
import fs from 'fs';
// import path from 'path';
import path from 'path';

function removeFullDir(dirPath: string) {
export function removeFullDir(dirPath: string) {
if (fs.existsSync(dirPath) && fs.statSync(dirPath).isDirectory()) {
fs.rmSync(dirPath, { recursive: true });
}
}

export { removeFullDir };
export function projectRootPath(...args: string[]) {
const pathList = Array.from(args);
const baseDir = path.join(__dirname, '..', '..');
return path.join(baseDir, ...pathList);
}

export function readJSONFile(...args: string[]) {
const filePath = projectRootPath(...args);
const jsonStr = fs.readFileSync(filePath, { encoding: 'utf8' });
const json = JSON.parse(jsonStr);
return json;
}

export function writeJSONFile(filePath: string, json: any) {
const fullPath = projectRootPath(filePath);
const jsonStr = JSON.stringify(json, null, 2);
fs.writeFileSync(fullPath, jsonStr);
}
25 changes: 21 additions & 4 deletions scripts/util/project.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import fs from 'fs';
import path from 'path';
import { globSync } from 'glob';
import { projectRootPath } from './file';

export function joinPackagePath(...args: string[]) {
const pathList = Array.from(args);
Expand All @@ -8,9 +10,7 @@ export function joinPackagePath(...args: string[]) {
}

export function joinProjectPath(...args: string[]) {
const pathList = Array.from(args);
const baseDir = path.join(__dirname, '..', '..');
return path.join(baseDir, ...pathList);
return projectRootPath(...args);
}

export function getTsConfig() {
Expand All @@ -20,8 +20,25 @@ export function getTsConfig() {
return config;
}

export function getRootPackageJSON() {
const configPath = joinProjectPath('package.json');
const configStr = fs.readFileSync(configPath, { encoding: 'utf8' });
const config = JSON.parse(configStr);
return config;
}

export function getAllSubPackageDirs() {
const pkgDirs = globSync('*', {
cwd: joinProjectPath('packages'),
absolute: false
});
return pkgDirs;
}

module.exports = {
joinProjectPath,
joinPackagePath,
getTsConfig
getTsConfig,
getRootPackageJSON,
getAllSubPackageDirs
};
Loading