Skip to content

Commit

Permalink
initial package / build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kenotron committed Aug 12, 2021
1 parent 45823bc commit 028a688
Show file tree
Hide file tree
Showing 17 changed files with 6,023 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{js,json,.yml}]
charset = utf-8
indent_style = space
indent_size = 2
13 changes: 13 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2019,
"sourceType": "module"
},
"env": {
"browser": true,
"es6": true,
"node": true
},
"ignorePatterns": ["**/coverage", "**/lib", "**/temp"]
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.yarn/** linguist-vendored
24 changes: 24 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: PR

on:
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn install
- run: yarn ci
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

on:
workflow_dispatch:
push:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.repo_pat }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn install
- run: yarn ci
- run: |
git config user.email "[email protected]"
git config user.name "Graphitation Service Account"
- run: yarn types
- run: yarn release -y -n $NPM_AUTHTOKEN --access public
env:
NPM_AUTHTOKEN: ${{ secrets.npm_authtoken }}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
lib
.tsbuildinfo

# This is purely pre-cautionary; when linting becomes slow, delete this eslintcache entry
.eslintcache

*.tgz
9 changes: 9 additions & 0 deletions lage.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
pipeline: {
types: ["^types"],
build: [],
test: ["build"],
lint: [],
},
npmClient: "yarn",
};
28 changes: 28 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@nova/monorepo",
"private": true,
"workspaces": {
"packages": [
"packages/*",
"scripts"
]
},
"scripts": {
"clean": "git clean -fdx -e node_modules",
"build": "lage build",
"types": "lage types",
"test": "lage test",
"lint": "lage lint",
"lage": "lage",
"ci": "yarn lage build types test lint && yarn checkchange",
"beachball": "beachball -b origin/main",
"change": "yarn beachball change",
"checkchange": "yarn beachball check",
"release": "yarn beachball publish"
},
"devDependencies": {
"beachball": "2.10.2",
"lage": "0.32.1",
"prettier": "^2.2.1"
}
}
21 changes: 21 additions & 0 deletions packages/a-package/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@nova/a-package",
"version": "0.1.0",
"main": "./src/index.ts",
"scripts": {
"build": "monorepo-scripts build",
"lint": "monorepo-scripts lint",
"test": "monorepo-scripts test",
"types": "monorepo-scripts types",
"just": "monorepo-scripts"
},
"devDependencies": {
"@types/jest": "^26.0.22",
"monorepo-scripts": "*"
},
"publishConfig": {
"main": "./lib/index",
"types": "./lib/index.d.ts",
"access": "public"
}
}
5 changes: 5 additions & 0 deletions packages/a-package/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe("index", () => {
it("runs", async () => {
expect(true).toEqual(true);
});
});
1 change: 1 addition & 0 deletions packages/a-package/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const aThing = "thing";
8 changes: 8 additions & 0 deletions scripts/bin/monorepo-scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env node

const path = require("path");
const { addResolvePath } = require("just-scripts");
addResolvePath(path.join(__dirname, ".."));

// Calling the CLI
require("just-scripts/bin/just-scripts");
6 changes: 6 additions & 0 deletions scripts/config/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
preset: "ts-jest",
rootDir: process.cwd(),
roots: ["<rootDir>/src"],
testPathIgnorePatterns: ["node_modules", "__generated__"],
};
48 changes: 48 additions & 0 deletions scripts/just.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {
tscTask,
esbuildTask,
jestTask,
eslintTask,
argv,
parallel,
EsbuildBuildOptions,
} from "just-scripts";
import * as path from "path";
import * as glob from "fast-glob";

export const types = tscTask({ emitDeclarationOnly: true });

export const build = () => {
const baseEsbuildOptions: EsbuildBuildOptions = {
entryPoints: glob.sync(["src/**/*.{ts,tsx}", "!src/**/__tests__/**"]),
outdir: "lib",
target: "es6",
};
return parallel(
esbuildTask({
...baseEsbuildOptions,
format: "esm",
outExtension: { ".js": ".mjs" },
}),
esbuildTask({
...baseEsbuildOptions,
format: "cjs",
})
);
};

export const test = () => {
return jestTask({
config: path.join(__dirname, "config", "jest.config.js"),
watch: argv().watch,
_: argv()._,
});
};

export const lint = eslintTask({
files: [path.join(process.cwd(), "src")],
extensions: ".ts,.tsx",
cache: true,
fix: process.argv.includes("--fix"),
timing: process.argv.includes("--timing"),
});
22 changes: 22 additions & 0 deletions scripts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "monorepo-scripts",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"private": true,
"bin": {
"monorepo-scripts": "bin/monorepo-scripts.js"
},
"devDependencies": {
"jest": "^26.6.3",
"typescript": "^4.2.3",
"ts-jest": "^26.5.4",
"just-scripts": "^1.5.3",
"ts-node": "^9.1.1",
"esbuild": "^0.11.5",
"eslint": "^7.23.0",
"@typescript-eslint/parser": "^4.21.0",
"@typescript-eslint/eslint-plugin": "4.7.0",
"fast-glob": "^3.2.5"
}
}
12 changes: 12 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "ES2019",
"module": "ES6",
"moduleResolution": "Node",
"declaration": true,
"declarationMap": true,
"strict": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
}
}
Loading

0 comments on commit 028a688

Please sign in to comment.