diff --git a/.github/workflows/publish-beta-to-npm.yaml b/.github/workflows/publish-beta-to-npm.yaml deleted file mode 100644 index bea5226..0000000 --- a/.github/workflows/publish-beta-to-npm.yaml +++ /dev/null @@ -1,42 +0,0 @@ -name: publish-beta-to-npm - -on: - push: - branches: - - main - - master - -jobs: - publish-beta-to-npm: - runs-on: ubuntu-latest - if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" - steps: - - name: Checkout release branch code - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - - uses: pnpm/action-setup@v2 - with: - version: 8 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: "pnpm" - registry-url: "https://registry.npmjs.org" - - - name: Install deps - run: pnpm install - - - name: Build - run: pnpm build - - - name: Publish to NPM - run: | - node scripts/update-beta-package-version.js - cat package.json | grep version - npm publish --tag beta - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/publish-to-npm.yaml b/.github/workflows/publish-to-npm.yaml index 5cbcc6a..9dcc8bc 100644 --- a/.github/workflows/publish-to-npm.yaml +++ b/.github/workflows/publish-to-npm.yaml @@ -3,8 +3,8 @@ name: publish-to-npm on: push: branches: - - main - master + - main jobs: publish-to-npm: diff --git a/package.json b/package.json index 50ea88d..529cbec 100644 --- a/package.json +++ b/package.json @@ -89,9 +89,5 @@ "directories": { "lib": "lib", "test": "test" - }, - "dependencies": { - "dayjs": "^1.11.13", - "fs-extra": "^11.2.0" } } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 58bdd49..5135785 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,13 +7,6 @@ settings: importers: .: - dependencies: - dayjs: - specifier: ^1.11.13 - version: 1.11.13 - fs-extra: - specifier: ^11.2.0 - version: 11.2.0 devDependencies: '@babel/cli': specifier: ^7.8.4 @@ -1401,9 +1394,6 @@ packages: resolution: {integrity: sha512-t/Ygsytq+R995EJ5PZlD4Cu56sWa8InXySaViRzw9apusqsOO2bQP+SbYzAhR0pFKoB+43lYy8rWban9JSuXnA==} engines: {node: '>= 0.4'} - dayjs@1.11.13: - resolution: {integrity: sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==} - debug@3.2.7: resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} peerDependencies: @@ -1689,10 +1679,6 @@ packages: resolution: {integrity: sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==} engines: {node: '>=14'} - fs-extra@11.2.0: - resolution: {integrity: sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==} - engines: {node: '>=14.14'} - fs-readdir-recursive@1.1.0: resolution: {integrity: sha512-GNanXlVr2pf02+sPN40XN8HG+ePaNcvM0q5mZBd668Obwb0yD5GiUbZOFgwn8kGMY6I3mdyDJzieUy3PTYyTRA==} @@ -2132,9 +2118,6 @@ packages: engines: {node: '>=6'} hasBin: true - jsonfile@6.1.0: - resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==} - kleur@3.0.3: resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} engines: {node: '>=6'} @@ -2755,10 +2738,6 @@ packages: resolution: {integrity: sha512-6t3foTQI9qne+OZoVQB/8x8rk2k1eVy1gRXhV3oFQ5T6R1dqQ1xtin3XqSlx3+ATBkliTaR/hHyJBm+LVPNM8w==} engines: {node: '>=4'} - universalify@2.0.1: - resolution: {integrity: sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==} - engines: {node: '>= 10.0.0'} - update-browserslist-db@1.1.0: resolution: {integrity: sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ==} hasBin: true @@ -4496,8 +4475,6 @@ snapshots: es-errors: 1.3.0 is-data-view: 1.0.1 - dayjs@1.11.13: {} - debug@3.2.7: dependencies: ms: 2.1.3 @@ -4873,12 +4850,6 @@ snapshots: cross-spawn: 7.0.3 signal-exit: 4.1.0 - fs-extra@11.2.0: - dependencies: - graceful-fs: 4.2.11 - jsonfile: 6.1.0 - universalify: 2.0.1 - fs-readdir-recursive@1.1.0: {} fs.realpath@1.0.0: {} @@ -5486,12 +5457,6 @@ snapshots: json5@2.2.3: {} - jsonfile@6.1.0: - dependencies: - universalify: 2.0.1 - optionalDependencies: - graceful-fs: 4.2.11 - kleur@3.0.3: {} leven@3.1.0: {} @@ -6110,8 +6075,6 @@ snapshots: unicode-property-aliases-ecmascript@2.1.0: {} - universalify@2.0.1: {} - update-browserslist-db@1.1.0(browserslist@4.23.3): dependencies: browserslist: 4.23.3 diff --git a/scripts/libs/work-spaces.js b/scripts/libs/work-spaces.js deleted file mode 100644 index 46ca2ce..0000000 --- a/scripts/libs/work-spaces.js +++ /dev/null @@ -1,101 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { join } = require("path"); -const { existsSync, readdirSync } = require("fs-extra"); -const { readJsonSync } = require("fs-extra"); -const { outputFileSync } = require("fs-extra"); -const { isArray } = require("lodash"); - -class WorkSpaces { - /** - * @type {string} - */ - rootDir; - - /** - * @type {string[]} - * @example ['core', 'services', 'packages'] - */ - workSpaces; - - includeWorkspaceRoot; - - #packageJson = "package.json"; - - constructor({ rootDir, workSpaces, includeWorkspaceRoot }) { - this.rootDir = rootDir; - this.workSpaces = workSpaces; - this.includeWorkspaceRoot = includeWorkspaceRoot; - } - - async setVersion(version) { - return this.#setVersion(version); - } - - async #setVersion(version) { - const packageJsonPaths = await this.#getPackageJsonPaths(); - - await Promise.all( - packageJsonPaths.map((packageJsonPath) => - this.#setPackageVersion(packageJsonPath, version) - ) - ); - } - - /** - * - * @param {string} packageJsonPath - * @param {string} version - * @returns {Promise} - */ - async #setPackageVersion(packageJsonPath, version) { - const packageJson = readJsonSync(packageJsonPath); - packageJson.version = version; - outputFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)); - } - - /** - * - * @returns {Promise} - */ - async #getPackageJsonPaths() { - const packageJsonPaths = []; - - if ( - this.includeWorkspaceRoot && - existsSync(join(this.rootDir, this.#packageJson)) - ) { - packageJsonPaths.push(join(this.rootDir, this.#packageJson)); - } - - if (!isArray(this.workSpaces)) { - return packageJsonPaths; - } - - for (const workspace of this.workSpaces) { - if (!existsSync(join(this.rootDir, workspace))) { - throw new Error(`workspace(${workspace}) not found`); - } - - const files = readdirSync(workspace, { withFileTypes: true }); - - for (const file of files) { - if ( - file.isDirectory() && - existsSync( - join(this.rootDir, workspace, file.name, this.#packageJson) - ) - ) { - packageJsonPaths.push( - join(this.rootDir, workspace, file.name, this.#packageJson) - ); - } - } - } - - return packageJsonPaths; - } -} - -module.exports = { - WorkSpaces, -}; diff --git a/scripts/update-beta-package-version.js b/scripts/update-beta-package-version.js deleted file mode 100644 index 34ecb23..0000000 --- a/scripts/update-beta-package-version.js +++ /dev/null @@ -1,20 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { WorkSpaces } = require("./libs/work-spaces"); -const { cwd } = require("process"); -const utc = require("dayjs/plugin/utc"); -const dayjs = require("dayjs"); -const { join } = require("path"); -const { readJSONSync } = require("fs-extra"); -dayjs.extend(utc); - -const currentVersion = readJSONSync( - join(cwd(), "package.json") -).version.replace(/-.*/, ""); -const time = dayjs().utcOffset(8).format("YYYY-MM-DD-HH-mm-SSS"); - -const newVersion = `${currentVersion}-beta-${time}`; -const workspace = new WorkSpaces({ - rootDir: cwd(), - includeWorkspaceRoot: true, -}); -workspace.setVersion(newVersion);