Skip to content

Commit

Permalink
added publishing script and updated versions
Browse files Browse the repository at this point in the history
  • Loading branch information
e11sy committed Aug 20, 2024
1 parent b56e61a commit bb7db6c
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 12 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,11 @@ jobs:
node-version: 22.1.0
registry-url: 'https://registry.npmjs.org/'

- name: Add npmrc file
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc

- name: Install dependencies
run: yarn install

- name: Build all packages
run: yarn build

- name: Publish all packages
run: yarn workspaces foreach --all --no-private npm publish --access public
run: yarn publish:ci
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"test": "vitest run",
"lint": "eslint",
"lint:fix": "yarn lint --fix",
"generate-docs": "ts-node scripts/generateReadme.ts"
"generate-docs": "ts-node scripts/generateReadme.ts",
"publish:ci": "ts-node scripts/publish.ts"
},
"devDependencies": {
"@types/fs-extra": "^11",
Expand Down
5 changes: 4 additions & 1 deletion packages/caret/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"name": "@editorjs/caret",
"description": "Utils useful for work with caret for Editor.js tools development",
"version": "0.0.4",
"version": "0.0.5",
"main": "dist/index.js",
"license": "MIT",
"scripts": {
"build": "tsc"
},
"dependencies": {
"@editorjs/dom": "workspace:^"
},
"publishConfig": {
"access": "public"
}
}
5 changes: 4 additions & 1 deletion packages/dom/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"name": "@editorjs/dom",
"description": "Utils useful for work with dom for Editor.js tools development",
"version": "0.0.4",
"version": "0.0.6",
"main": "dist/index.js",
"license": "MIT",
"scripts": {
"build": "tsc"
},
"dependencies": {
"@editorjs/helpers": "workspace:^"
},
"publishConfig": {
"access": "public"
}
}
5 changes: 4 additions & 1 deletion packages/helpers/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"name": "@editorjs/helpers",
"description": "Utils useful for Editor.js tools development",
"version": "0.0.4",
"version": "0.0.5",
"main": "dist/index.js",
"license": "MIT",
"scripts": {
"build": "tsc --project tsconfig.build.json"
},
"publishConfig": {
"access": "public"
}
}
5 changes: 4 additions & 1 deletion packages/keyboard/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"name": "@editorjs/keyboard",
"description": "Utils useful for work with keyboard for Editor.js tools development",
"version": "0.0.4",
"version": "0.0.5",
"main": "dist/index.js",
"license": "MIT",
"scripts": {
"build": "tsc"
},
"publishConfig": {
"access": "public"
}
}
39 changes: 39 additions & 0 deletions scripts/publish.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { execSync } from 'child_process';
import * as path from 'path';
import { pathExistsSync, statSync, readdirSync } from 'fs-extra';

const packagesDir = path.join(__dirname, '..', 'packages');

/**
* Function that returns names of all packages in /packages directory
*/
function getPackages(): string[] {
const directories = readdirSync(packagesDir).filter((dir) => {
/**
* Actutal path to the package in project
*/
const pathToPackage = path.join('packages', dir);

/**
* Check if path is a directory (not a file)
* Check if path contains package.json (directory is actually package and could be published)
*/
return statSync(pathToPackage).isDirectory() && pathExistsSync(path.join(pathToPackage, 'package.json'));
});

return directories;
}

execSync('npm run build', { stdio: 'inherit' });

let command = 'yarn npm publish --access public';

const packages = getPackages();

/**
* For each package run yarn npm publish
*/
for (const name of packages) {
execSync(command, { stdio: 'inherit',
cwd: path.join('packages', name) });
}

0 comments on commit bb7db6c

Please sign in to comment.