Skip to content

Commit

Permalink
chore: move to nx monorepo integrated mode (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvaroraminelli authored Nov 14, 2023
1 parent 399d938 commit 9161323
Show file tree
Hide file tree
Showing 27 changed files with 8,725 additions and 562 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
42 changes: 42 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
},
"rules": {}
}
]
}
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Add files here to ignore them from prettier formatting
/dist
/coverage
/.nx/cache
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
28 changes: 28 additions & 0 deletions .verdaccio/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# path to a directory with all packages
storage: ../tmp/local-registry/storage

# a list of other known repositories we can talk to
uplinks:
npmjs:
url: https://registry.npmjs.org/
maxage: 60m

packages:
'**':
# give all users (including non-authenticated users) full access
# because it is a local registry
access: $all
publish: $all
unpublish: $all

# if package is not available locally, proxy requests to npm registry
proxy: npmjs

# log settings
logs:
type: stdout
format: pretty
level: warn

publish:
allow_offline: true # set offline to true to allow publish offline
5 changes: 5 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { getJestProjects } from '@nx/jest';

export default {
projects: getJestProjects(),
};
3 changes: 3 additions & 0 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const nxPreset = require('@nx/jest/preset').default;

module.exports = { ...nxPreset };
56 changes: 53 additions & 3 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,56 @@
{
"targetDefaults": {},
"affected": {
"defaultBase": "main"
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"targetDefaults": {
"build": {
"cache": true,
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"lint": {
"cache": true,
"inputs": [
"default",
"{workspaceRoot}/.eslintrc.json",
"{workspaceRoot}/.eslintignore",
"{workspaceRoot}/eslint.config.js"
]
},
"e2e": {
"cache": true,
"inputs": ["default", "^production"]
},
"@nx/jest:jest": {
"cache": true,
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
"options": {
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": [
"default",
"!{projectRoot}/.eslintrc.json",
"!{projectRoot}/eslint.config.js",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/src/test-setup.[jt]s",
"!{projectRoot}/test-setup.[jt]s"
],
"sharedGlobals": []
},
"generators": {},
"pluginsConfig": {
"@nx/js": {
"analyzeSourceFiles": true
}
}
}
51 changes: 47 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"name": "@base-org/build-onchain-apps",
"version": "0.0.4",
"repository": "https://github.com/base-org/build-onchain-apps.git",
"dependencies": {
"commander": "^11.1.0",
"figlet": "^1.7.0",
"tslib": "^2.3.0"
},
"scripts": {
"build": "echo 'Coming soon'",
"format": "nx run-many --target=format --all",
Expand All @@ -12,15 +17,53 @@
"release:publish": "yarn install && yarn build && changeset publish",
"release:version": "changeset version && yarn install --lockfile-only"
},
"dependencies": {
"@base-org/build-onchain-apps": "^0.0.4"
},
"devDependencies": {
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"nx": "17.0.3"
"@nx/cypress": "17.1.2",
"@nx/eslint": "17.1.2",
"@nx/eslint-plugin": "17.1.2",
"@nx/jest": "17.1.2",
"@nx/js": "17.1.2",
"@nx/next": "^17.1.2",
"@nx/react": "17.1.2",
"@nx/workspace": "17.1.2",
"@swc-node/register": "~1.6.7",
"@swc/core": "~1.3.85",
"@testing-library/react": "14.0.0",
"@types/figlet": "^1.5.8",
"@types/inquirer": "^8.2.5",
"@types/jest": "^29.4.0",
"@types/node": "18.14.2",
"@types/react": "18.2.33",
"@types/react-dom": "18.2.14",
"@types/tar": "4.0.3",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"babel-jest": "^29.4.1",
"cypress": "^13.0.0",
"eslint": "~8.46.0",
"eslint-config-next": "13.4.1",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-cypress": "^2.13.4",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-react": "7.32.2",
"eslint-plugin-react-hooks": "4.6.0",
"jest": "^29.4.1",
"jest-environment-jsdom": "^29.4.1",
"jest-environment-node": "^29.4.1",
"nx": "17.1.2",
"prettier": "^2.6.2",
"ts-jest": "^29.1.0",
"ts-node": "10.9.1",
"typescript": "~5.2.2",
"verdaccio": "^5.0.4"
},
"publishConfig": {
"access": "public"
},
"nx": {
"includedScripts": []
}
}
25 changes: 25 additions & 0 deletions packages/cli/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": "error"
}
}
]
}
10 changes: 0 additions & 10 deletions packages/cli/.gitignore

This file was deleted.

25 changes: 14 additions & 11 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# Build Onchain Apps CLI

## Running Locally
## How to run it

1. First build
To get started, open a new shell and run:

```bash
yarn
yarn build
```
npx build-onchain-apps@latest create buy-me-a-coffee-app
```

## Local Development

To test the CLI locally, run:

2. Install the CLI globally
1. Run the local NPM registry:

```bash
yarn global add "file:$PWD"
```
npx nx local-registry
```

3. Test it out
2. In a different window, publish a new version of the packages:

```bash
build-onchain-apps
```
npx nx run-many -t publish --ver 0.0.1 --tag latest
```
File renamed without changes.
11 changes: 11 additions & 0 deletions packages/cli/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'cli',
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/packages/cli',
};
15 changes: 9 additions & 6 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"name": "@base-org/build-onchain-apps",
"name": "build-onchain-apps",
"version": "0.0.1",
"description": "Build Onchain Apps CLI",
"main": "dist/index.js",
"bin": {
"build-onchain-apps": "./dist/index.js"
},
"scripts": {
"build": "npx tsc",
"test": "echo \"Error: no test specified\" && exit 1"
Expand All @@ -15,11 +11,18 @@
"license": "ISC",
"dependencies": {
"commander": "^11.1.0",
"figlet": "^1.7.0"
"figlet": "^1.7.0",
"tslib": "^2.3.0"
},
"devDependencies": {
"@types/figlet": "^1.5.8",
"@types/node": "^20.9.0",
"typescript": "^5.2.2"
},
"type": "commonjs",
"main": "./src/index.js",
"typings": "./src/index.d.ts",
"bin": {
"build-onchain-apps": "./bin/index.js"
}
}
41 changes: 41 additions & 0 deletions packages/cli/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "cli",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/cli/bin",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/cli",
"main": "packages/cli/bin/index.ts",
"tsConfig": "packages/cli/tsconfig.lib.json",
"assets": ["packages/cli/*.md"],
"updateBuildableProjectDepsInPackageJson": false
}
},
"publish": {
"command": "node tools/scripts/publish.mjs cli {args.ver} {args.tag}",
"dependsOn": ["build"]
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"packages/cli/**/*.ts",
"packages/cli/package.json"
]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/cli/jest.config.ts"
}
}
},
"tags": []
}
Loading

0 comments on commit 9161323

Please sign in to comment.