Skip to content

feat: add script to copy license and readme to packages #6

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

Merged
merged 1 commit into from
Jul 10, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/publish-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ jobs:
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Pre Publish hook call
run: pnpm workspace:prePublish
- name: publish
run: pnpm workspace:publish
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
.idea
packages/**/README.md
packages/**/LICENSE.md
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"name": "@dotmh/linting",
"version": "1.0.0",
"version": "2.0.0",
"description": "A Monorepo that shares linting configurations across DotMH projects",
"private": true,
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"workspace:publish": "pnpm publish -r --no-git-checks",
"workspace:copyFiles": "node scripts/copy.js",
"workspace:prePublish": "pnpm workspace:copyFiles",
"prepare": "husky",
"lint:commit": "commitlint --edit",
"githook:commitMessage": "pnpm lint:commit"
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dotmh/eslint-config-ts",
"version": "1.0.0",
"version": "2.0.0",
"description": "A ESLint file for all DotMH Typescript projects",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/prettier-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dotmh/prettier-config",
"version": "1.0.0",
"version": "2.0.0",
"description": "A Prettier config for DotMH.io projects",
"main": "index.json",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/tsconfig/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dotmh/tsconfig",
"version": "1.0.0",
"version": "2.0.0",
"description": "A Shared config for Typescript",
"exports": "./tsconfig.json",
"files": [
Expand Down
32 changes: 32 additions & 0 deletions scripts/copy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { readdir, readFile, writeFile } from "node:fs/promises";
import { resolve, dirname, join } from "node:path";
import { fileURLToPath } from "node:url";

const FILES = ["README.md", "LICENSE.md"];
const PACKAGES = "packages";

// Add back __dirname
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
const __dirname = dirname(__filename); // get the name of the directory

const main = async () => {
const base = resolve(__dirname, "..");
const sources = await Promise.all(
FILES.map((file) => readFile(join(base, file), "utf-8"))
);

const pkgPath = join(base, PACKAGES);
const folders = await readdir(pkgPath);

await Promise.all(
folders.map((folder) => {
return Promise.all(
sources.map((file, i) => {
return writeFile(join(pkgPath, folder, FILES[i]), file, "utf-8");
})
);
})
);
};

main().catch((error) => console.log(error));