-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #218 from idrawjs/dev-v0.4
Dev v0.4
- Loading branch information
Showing
13 changed files
with
136 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters