Skip to content

Commit

Permalink
build: scaffold repo with nx
Browse files Browse the repository at this point in the history
  • Loading branch information
jordan-a-young committed Feb 1, 2023
1 parent e079638 commit cf55db5
Show file tree
Hide file tree
Showing 21 changed files with 13,568 additions and 40 deletions.
4 changes: 4 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": ["@commitlint/config-conventional"],
"rules": {}
}
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
11 changes: 11 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.yarn
!.storybook/

docs/
storybook-docs/
coverage/
static/

/**/.docusaurus
/**/build
/**/dist
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": ["@nrwl/nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"vite": true
},
"rules": {}
}
]
}
60 changes: 22 additions & 38 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# compiled output
dist
tmp
/out-tsc

# Runtime data
pids
*.pid
*.seed
*.pid.lock
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
Expand Down Expand Up @@ -65,40 +68,21 @@ typings/
# Output of 'npm pack'
*.tgz

# Yarn Integrity file
# Yarn
.yarn-integrity
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
yarn-error.log
.pnp.*

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
# System Files
.DS_Store
Thumbs.db
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
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
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 120,
"tabWidth": 2
}
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"nrwl.angular-console",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"firsttris.vscode-jest-runner"
]
}
541 changes: 541 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

823 changes: 823 additions & 0 deletions .yarn/releases/yarn-3.3.1.cjs

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: '@yarnpkg/plugin-interactive-tools'

yarnPath: .yarn/releases/yarn-3.3.1.cjs

npmPublishRegistry: 'https://registry.npmjs.org/'

npmRegistryServer: 'https://registry.npmjs.org/'
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
# element
React components for the Availity design system Element
# availity-element

<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a>

**This workspace has been generated by [Nx, a Smart, fast and extensible build system.](https://nx.dev)**

## Understand this workspace

Run `nx graph` to see a diagram of the dependencies of the projects.

## Remote caching

Run `npx nx connect-to-nx-cloud` to enable [remote caching](https://nx.app) and make CI faster.

## Further help

Visit the [Nx Documentation](https://nx.dev) to learn more.
49 changes: 49 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"npmScope": "availity",
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": ["build", "lint", "test", "e2e"]
}
}
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"lint": {
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"]
},
"test": {
"inputs": ["default", "^production"]
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": [
"default",
"!{projectRoot}/.eslintrc.json",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/vite.config.[jt]s"
],
"sharedGlobals": []
},
"workspaceLayout": {
"appsDir": "apps",
"libsDir": "packages"
},
"generators": {
"@nrwl/react": {
"application": {
"babel": true
},
"library": {
"unitTestRunner": "vite"
}
}
}
}
71 changes: 71 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"name": "availity-element-monorepo",
"version": "0.0.0",
"description": "React component library for the Availity design system",
"repository": "https://github.com/Availity/element.git",
"author": "Jordan Young <[email protected]>",
"license": "MIT",
"private": true,
"workspaces": [
"packages/*"
],
"packageManager": "[email protected]",
"devDependencies": {
"@babel/preset-react": "^7.18.6",
"@commitlint/cli": "^17.0.0",
"@commitlint/config-conventional": "^17.0.0",
"@emotion/babel-plugin": "11.10.5",
"@jscutlery/semver": "^2.29.3",
"@nrwl/eslint-plugin-nx": "15.6.2",
"@nrwl/jest": "15.6.2",
"@nrwl/js": "15.6.2",
"@nrwl/linter": "15.6.2",
"@nrwl/react": "15.6.2",
"@nrwl/vite": "15.6.2",
"@nrwl/workspace": "15.6.2",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "13.4.0",
"@types/jest": "28.1.1",
"@types/node": "18.11.9",
"@types/react": "18.0.25",
"@types/react-dom": "18.0.9",
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"@vitejs/plugin-react": "^3.0.0",
"@vitest/ui": "^0.25.8",
"babel-jest": "28.1.1",
"eslint": "~8.15.0",
"eslint-config-prettier": "8.1.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jsx-a11y": "6.6.1",
"eslint-plugin-react": "7.31.11",
"eslint-plugin-react-hooks": "4.6.0",
"husky": "^8.0.0",
"jest": "28.1.1",
"jest-environment-jsdom": "28.1.1",
"jsdom": "~20.0.3",
"nx": "15.6.2",
"prettier": "^2.6.2",
"react-test-renderer": "18.2.0",
"ts-jest": "28.0.5",
"ts-node": "10.9.1",
"typescript": "~4.8.2",
"vite": "^4.0.1",
"vite-plugin-dts": "~1.7.1",
"vite-plugin-eslint": "^1.8.1",
"vite-tsconfig-paths": "^4.0.2",
"vitest": "^0.25.8"
},
"dependencies": {
"@availity/design-tokens": "0.5.0-alpha.0",
"@mui/material": "^5.11.6",
"@mui/x-date-pickers": "^5.0.15",
"date-fns": "^2.29.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"tslib": "^2.3.0"
},
"scripts": {
"prepare": "husky install"
}
}
Empty file added tools/generators/.gitkeep
Empty file.
61 changes: 61 additions & 0 deletions tools/scripts/publish.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* This is a minimal script to publish your package to "npm".
* This is meant to be used as-is or customize as you see fit.
*
* This script is executed on "dist/path/to/library" as "cwd" by default.
*
* You might need to authenticate with NPM before running this script.
*/

import { readCachedProjectGraph } from '@nrwl/devkit';
import { execSync } from 'child_process';
import { readFileSync, writeFileSync } from 'fs';
import chalk from 'chalk';

function invariant(condition, message) {
if (!condition) {
console.error(chalk.bold.red(message));
process.exit(1);
}
}

// Executing publish script: node path/to/publish.mjs {name} --version {version} --tag {tag}
// Default "tag" to "next" so we won't publish the "latest" tag by accident.
const [, , name, version, tag = 'next'] = process.argv;

// A simple SemVer validation to validate the version
const validVersion = /^\d+\.\d+\.\d+(-\w+\.\d+)?/;
invariant(
version && validVersion.test(version),
`No version provided or version did not match Semantic Versioning, expected: #.#.#-tag.# or #.#.#, got ${version}.`
);

const graph = readCachedProjectGraph();
const project = graph.nodes[name];

invariant(
project,
`Could not find project "${name}" in the workspace. Is the project.json configured correctly?`
);

const outputPath = project.data?.targets?.build?.options?.outputPath;
invariant(
outputPath,
`Could not find "build.options.outputPath" of project "${name}". Is project.json configured correctly?`
);

process.chdir(outputPath);

// Updating the version in "package.json" before publishing
try {
const json = JSON.parse(readFileSync(`package.json`).toString());
json.version = version;
writeFileSync(`package.json`, JSON.stringify(json, null, 2));
} catch (e) {
console.error(
chalk.bold.red(`Error reading package.json file from library build output.`)
);
}

// Execute "npm publish" to publish
execSync(`npm publish --access public --tag ${tag}`);
Loading

0 comments on commit cf55db5

Please sign in to comment.