Skip to content

Commit d882eb5

Browse files
authored
Merge pull request #6 from dotmh/feature/add-readme-license-to-pkg
feat: add script to copy license and readme to packages
2 parents f755e73 + 94ac014 commit d882eb5

File tree

7 files changed

+42
-4
lines changed

7 files changed

+42
-4
lines changed

.github/workflows/publish-action.yml

+2
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ jobs:
2323
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
2424
env:
2525
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
26+
- name: Pre Publish hook call
27+
run: pnpm workspace:prePublish
2628
- name: publish
2729
run: pnpm workspace:publish

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules
22
.idea
3+
packages/**/README.md
4+
packages/**/LICENSE.md

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
22
"name": "@dotmh/linting",
3-
"version": "1.0.0",
3+
"version": "2.0.0",
44
"description": "A Monorepo that shares linting configurations across DotMH projects",
55
"private": true,
66
"main": "index.js",
77
"type": "module",
88
"scripts": {
99
"test": "echo \"Error: no test specified\" && exit 1",
1010
"workspace:publish": "pnpm publish -r --no-git-checks",
11+
"workspace:copyFiles": "node scripts/copy.js",
12+
"workspace:prePublish": "pnpm workspace:copyFiles",
1113
"prepare": "husky",
1214
"lint:commit": "commitlint --edit",
1315
"githook:commitMessage": "pnpm lint:commit"

packages/eslint-config-ts/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dotmh/eslint-config-ts",
3-
"version": "1.0.0",
3+
"version": "2.0.0",
44
"description": "A ESLint file for all DotMH Typescript projects",
55
"main": "index.js",
66
"scripts": {

packages/prettier-config/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dotmh/prettier-config",
3-
"version": "1.0.0",
3+
"version": "2.0.0",
44
"description": "A Prettier config for DotMH.io projects",
55
"main": "index.json",
66
"scripts": {

packages/tsconfig/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dotmh/tsconfig",
3-
"version": "1.0.0",
3+
"version": "2.0.0",
44
"description": "A Shared config for Typescript",
55
"exports": "./tsconfig.json",
66
"files": [

scripts/copy.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { readdir, readFile, writeFile } from "node:fs/promises";
2+
import { resolve, dirname, join } from "node:path";
3+
import { fileURLToPath } from "node:url";
4+
5+
const FILES = ["README.md", "LICENSE.md"];
6+
const PACKAGES = "packages";
7+
8+
// Add back __dirname
9+
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
10+
const __dirname = dirname(__filename); // get the name of the directory
11+
12+
const main = async () => {
13+
const base = resolve(__dirname, "..");
14+
const sources = await Promise.all(
15+
FILES.map((file) => readFile(join(base, file), "utf-8"))
16+
);
17+
18+
const pkgPath = join(base, PACKAGES);
19+
const folders = await readdir(pkgPath);
20+
21+
await Promise.all(
22+
folders.map((folder) => {
23+
return Promise.all(
24+
sources.map((file, i) => {
25+
return writeFile(join(pkgPath, folder, FILES[i]), file, "utf-8");
26+
})
27+
);
28+
})
29+
);
30+
};
31+
32+
main().catch((error) => console.log(error));

0 commit comments

Comments
 (0)