Skip to content
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

feat: migrate to nx workspace #1483

Draft
wants to merge 21 commits into
base: dev
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
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": {}
}
86 changes: 0 additions & 86 deletions .eslintrc.js

This file was deleted.

53 changes: 53 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"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": {
"@typescript-eslint/explicit-function-return-type": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}
]
}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
},
"rules": {}
}
]
}
6 changes: 0 additions & 6 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -17,12 +17,6 @@ jobs:
- name: Setup the project
run: |
yarn run setup
npx lerna add @pattern-lab/engine-mustache --scope=@pattern-lab/core
npx lerna add @pattern-lab/engine-handlebars --scope=@pattern-lab/core
npx lerna add @pattern-lab/engine-underscore --scope=@pattern-lab/core
npx lerna add @pattern-lab/engine-liquid --scope=@pattern-lab/core
npx lerna add @pattern-lab/engine-twig --scope=@pattern-lab/core
npx lerna add @pattern-lab/engine-react --scope=@pattern-lab/core
- name: Run Unit Tests
run: yarn run test
40 changes: 37 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,50 @@
node_modules/
pattern_exports/
.DS_Store
Thumbs.db
.nyc_output/
.idea/
.env
packages/core/test/public
packages/*/public
!packages/core/test/patterns/public/.gitkeep
!packages/core/test/patterns/testDependencyGraph.json
lerna-debug.log
packages/edition-node-gulp/dependencyGraph.json
packages/uikit-workshop/dist
.yarn

yarn-error.log

# compiled output
dist
tmp
/out-tsc

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
.env

# System Files
.DS_Store
Thumbs.db

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
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
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install pretty-quick --staged
# npx --no-install pretty-quick --staged
4 changes: 2 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
**/*.json
**/README.md
**/node_modules/
**/bower_components/
@@ -9,9 +8,10 @@ packages/core/scripts/api.handlebars
packages/core/scripts/events.handlebars
packages/core/test/files/annotations.js
packages/**/annotations.js
*.json
*.md
**/reset.scss
**/_meta/_head.*
**/_meta/_foot.*
**/development-edition*/source/_patterns/**
/dist
/coverage
7 changes: 6 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"singleQuote": true,
"endOfLine": "auto"
"endOfLine": "auto",
"trailingComma": "all",
"printWidth": 112,
"arrowParens": "always",
"useTabs": false,
"tabWidth": 2
}
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"recommendations": ["editorconfig.editorconfig", "henrynguyen5-vsc.vsc-nvm"]
"recommendations": ["editorconfig.editorconfig", "henrynguyen5-vsc.vsc-nvm", "firsttris.vscode-jest-runner"]
}
3 changes: 0 additions & 3 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -9,6 +9,3 @@

# uikit-workshop owner
/packages/uikit-workshop @sghoweri

# engine-nunjucks owner
/packages/engine-nunjucks @danwhite85
27 changes: 0 additions & 27 deletions babel.config.js

This file was deleted.

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(),
};
7 changes: 7 additions & 0 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const nxPreset = require('@nx/jest/preset').default;

module.exports = {
...nxPreset,
collectCoverage: true,
coverageReporters: ['lcov', 'text'],
};
38 changes: 0 additions & 38 deletions lerna.json

This file was deleted.

172 changes: 172 additions & 0 deletions migrations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
{
"migrations": [
{
"version": "15.7.0-beta.0",
"description": "Split global configuration files into individual project.json files. This migration has been added automatically to the beginning of your migration set to retroactively make them work with the new version of Nx.",
"cli": "nx",
"implementation": "./src/migrations/update-15-7-0/split-configuration-into-project-json-files",
"package": "@nx/workspace",
"name": "15-7-0-split-configuration-into-project-json-files"
},
{
"cli": "nx",
"version": "15.8.2-beta.0",
"description": "Updates the nx wrapper.",
"implementation": "./src/migrations/update-15-8-2/update-nxw",
"package": "nx",
"name": "15.8.2-update-nx-wrapper"
},
{
"cli": "nx",
"version": "16.0.0-beta.0",
"description": "Remove @nrwl/cli.",
"implementation": "./src/migrations/update-16-0-0/remove-nrwl-cli",
"package": "nx",
"name": "16.0.0-remove-nrwl-cli"
},
{
"cli": "nx",
"version": "16.0.0-beta.9",
"description": "Replace `dependsOn.projects` and `inputs` definitions with new configuration format.",
"implementation": "./src/migrations/update-16-0-0/update-depends-on-to-tokens",
"package": "nx",
"name": "16.0.0-tokens-for-depends-on"
},
{
"cli": "nx",
"version": "16.0.0-beta.0",
"description": "Replace @nrwl/nx-cloud with nx-cloud",
"implementation": "./src/migrations/update-16-0-0/update-nx-cloud-runner",
"package": "nx",
"name": "16.0.0-update-nx-cloud-runner"
},
{
"cli": "nx",
"version": "16.2.0-beta.0",
"description": "Remove outputPath from run commands",
"implementation": "./src/migrations/update-16-2-0/remove-run-commands-output-path",
"package": "nx",
"name": "16.2.0-remove-output-path-from-run-commands"
},
{
"version": "15.7.0-beta.0",
"description": "Split global configuration files (e.g., workspace.json) into individual project.json files.",
"cli": "nx",
"implementation": "./src/migrations/update-15-7-0/split-configuration-into-project-json-files",
"package": "@nx/workspace",
"name": "15-7-0-split-configuration-into-project-json-files"
},
{
"cli": "nx",
"version": "16.0.0-beta.1",
"description": "Replace @nx/workspace with @nx/workspace",
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages",
"package": "@nx/workspace",
"name": "update-16-0-0-add-nx-packages"
},
{
"version": "16.0.0-beta.4",
"description": "Generates a plugin called 'workspace-plugin' containing your workspace generators.",
"cli": "nx",
"implementation": "./src/migrations/update-16-0-0/move-workspace-generators-to-local-plugin",
"package": "@nx/workspace",
"name": "16-0-0-move-workspace-generators-into-local-plugin"
},
{
"version": "16.0.0-beta.9",
"description": "Fix .babelrc presets if it contains an invalid entry for @nx/web/babel.",
"cli": "nx",
"implementation": "./src/migrations/update-16-0-0/fix-invalid-babelrc",
"package": "@nx/workspace",
"name": "16-0-0-fix-invalid-babelrc"
},
{
"cli": "nx",
"version": "15.8.0-beta.0",
"description": "Rename .lib.swcrc to .swcrc for better SWC support throughout the workspace",
"factory": "./src/migrations/update-15-8-0/rename-swcrc-config",
"package": "@nx/js",
"name": "rename-swcrc-config"
},
{
"cli": "nx",
"version": "16.0.0-beta.1",
"description": "Replace @nx/js with @nx/js",
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages",
"package": "@nx/js",
"name": "update-16-0-0-add-nx-packages"
},
{
"cli": "nx",
"version": "16.0.0-beta.1",
"description": "Replace @nx/eslint-plugin with @nx/eslint-plugin",
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages",
"package": "@nx/eslint-plugin",
"name": "update-16-0-0-add-nx-packages"
},
{
"cli": "nx",
"version": "16.0.0-beta.1",
"description": "Replace @nx/web with @nx/web",
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages",
"package": "@nx/web",
"name": "update-16-0-0-add-nx-packages"
},
{
"cli": "nx",
"version": "16.0.0-beta.4",
"description": "Replace @nx/web executors with @nx/webpack and @nx/rollup",
"implementation": "./src/migrations/update-16-0-0-update-executors/update-16-0-0-update-executors",
"package": "@nx/web",
"name": "update-16-0-0-update-executors"
},
{
"cli": "nx",
"version": "15.7.1-beta.0",
"description": "Add node_modules to root eslint ignore",
"factory": "./src/migrations/update-15-7-1/add-eslint-ignore",
"package": "@nx/linter",
"name": "add-eslint-ignore"
},
{
"cli": "nx",
"version": "16.0.0-beta.1",
"description": "Replace @nx/linter with @nx/linter",
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages",
"package": "@nx/linter",
"name": "update-16-0-0-add-nx-packages"
},
{
"version": "15.8.0-beta.0",
"cli": "nx",
"description": "Update jest configs to support jest 29 changes (https://jestjs.io/docs/upgrading-to-jest29)",
"factory": "./src/migrations/update-15-8-0/update-configs-jest-29",
"package": "@nx/jest",
"name": "update-configs-jest-29"
},
{
"version": "15.8.0-beta.0",
"cli": "nx",
"description": "Update jest test files to support jest 29 changes (https://jestjs.io/docs/upgrading-to-jest29)",
"factory": "./src/migrations/update-15-8-0/update-tests-jest-29",
"package": "@nx/jest",
"name": "update-tests-jest-29"
},
{
"cli": "nx",
"version": "16.0.0-beta.1",
"description": "Replace @nx/jest with @nx/jest",
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages",
"package": "@nx/jest",
"name": "update-16-0-0-add-nx-packages"
},
{
"cli": "nx",
"version": "16.0.0-beta.1",
"description": "Replace @nx/webpack with @nx/webpack",
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages",
"package": "@nx/webpack",
"name": "update-16-0-0-add-nx-packages"
}
]
}
54 changes: 54 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"npmScope": "pattern-lab",
"affected": {
"defaultBase": "dev"
},
"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", "{workspaceRoot}/jest.preset.js"]
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*"],
"production": [
"default",
"!{projectRoot}/.eslintrc.json",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s"
]
},
"workspaceLayout": {
"appsDir": "packages",
"libsDir": "packages"
},
"generators": {
"@nx/web:application": {
"style": "scss",
"linter": "eslint",
"unitTestRunner": "jest",
"e2eTestRunner": "none"
},
"@nx/web:library": {
"style": "scss",
"linter": "eslint",
"unitTestRunner": "jest"
}
}
}
211 changes: 170 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,56 +1,185 @@
{
"workspaces": {
"packages": [
"packages/*"
],
"nohoist": [
"@pattern-lab/engine-*",
"**/@pattern-lab/engine-*",
"**/@pattern-lab/uikit-workshop"
]
},
"dependencies": {
"@auto-it/released": "^10.27.0",
"@babel/plugin-proposal-decorators": "^7.13.5",
"@babel/plugin-syntax-jsx": "^7.12.13",
"auto": "^10.27.0",
"babel-eslint": "^10.0.2",
"eslint": "^6.1.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-prettier": "^3.1.0",
"lerna": "4.0.0",
"prettier": "^2.8.1",
"pretty-quick": "^3.1.3"
},
"repository": {
"type": "git",
"url": "git+https://github.com/pattern-lab/patternlab-node.git"
},
"version": "6.0.1",
"private": true,
"scripts": {
"postinstall": "lerna run postbootstrap",
"postinstall": "yarn build:all",
"setup": "yarn",
"build:uikit": "cd packages/uikit-workshop && npm run build",
"precommit": "pretty-quick --staged",
"lint:fix": "npm run lint -- --fix",
"lint": "eslint --max-warnings 0 './packages/{core,cli,uikit-workshop}/**/*.js ' --ignore-path .eslintignore",
"test": "lerna run test",
"lint": "nx run-many --target=lint",
"test": "nx run-many --target=test",
"build:all": "nx run-many --target=build --configuration=production",
"version:all": "nx run-many --target=version --baseBranch=master --syncVersions --noVerify",
"dev:prepare": "symlink-dir dist/packages node_modules/@pattern-lab && nx run-many --target=pl:starterkit",
"dev:build:handlebars": "nx run development-edition-engine-handlebars:pl:build",
"dev:build:twig": "nx run development-edition-engine-twig:pl:build",
"dev:build:twig-php": "nx run development-edition-engine-twig-php:pl:build",
"dev:serve:handlebars": "nx run development-edition-engine-handlebars:pl:serve",
"dev:serve:twig": "nx run development-edition-engine-twig:pl:serve",
"dev:serve:twig-php": "nx run development-edition-engine-twig-php:pl:serve",
"clean": "git clean -dfx",
"publish": "npx lerna publish -m \"[skip travis] chore(release): publish %s\"",
"postpublish": "auto release",
"preview:docs": "cd packages/docs && yarn production",
"preview:hbs": "cd packages/development-edition-engine-handlebars && yarn pl:starterkit && yarn pl:build",
"prepare": "husky install"
},
"nyc": {
"exclude": [
"**/*_tests.js",
"packages/cli",
"packages/core/test",
"packages/live-server"
]
"dependencies": {
"@11ty/eleventy": "^0.12.1",
"@11ty/eleventy-plugin-rss": "^1.1.2",
"@11ty/eleventy-plugin-syntaxhighlight": "^3.1.3",
"@basalt/twig-renderer": "^2.0.0",
"@tbranyen/jsdom": "^13.0.0",
"archiver": "5.3.0",
"chalk": "^4.1.0",
"chokidar": "3.5.1",
"colors": "1.4.0",
"commander": "9.4.1",
"concurrently": "^4.1.0",
"connect": "3.7.0",
"cors": "2.8.5",
"deepmerge": "^4.2.2",
"dive": "0.5.0",
"event-stream": "3.3.4",
"execa": "5.0.0",
"faye-websocket": "0.11.x",
"fs-extra": "^10.0.0",
"glob": "^7.1.6",
"graphlib": "2.1.8",
"handlebars": "^4.7.7",
"has-yarn": "2.1.0",
"html-minifier": "^4.0.0",
"http-auth": "4.1.x",
"http-auth-connect": "^1.0.5",
"inquirer": "8.0.0",
"js-beautify": "1.13.5",
"js-yaml": "4.1.0",
"liquidjs": "10.4.0",
"lodash": "4.17.21",
"markdown-it": "12.3.2",
"morgan": "1.10.0",
"mustache": "3.1.0",
"node-fetch": "2.6.7",
"nunjucks": "^3.2.3",
"object-assign": "4.1.1",
"open": "8.0.9",
"ora": "5.4.0",
"proxy-middleware": "0.15.0",
"recursive-copy": "2.0.13",
"sass": "1.43.4",
"send": "0.18.0",
"serve-index": "1.9.1",
"slugify": "^1.5.0",
"tslib": "^2.3.0",
"twing": "^5.0.2",
"underscore": "1.13.0",
"update-notifier": "5.1.0"
},
"devDependencies": {
"husky": "^8.0.2"
"@11ty/eleventy-navigation": "^0.3.2",
"@auto-it/all-contributors": "10.38.5",
"@auto-it/conventional-commits": "10.38.5",
"@auto-it/first-time-contributor": "10.38.5",
"@auto-it/released": "^10.27.0",
"@babel/core": "^7.13.14",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-proposal-decorators": "^7.13.5",
"@babel/plugin-proposal-optional-chaining": "^7.13.12",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-jsx": "^7.12.13",
"@babel/plugin-transform-react-jsx": "^7.13.12",
"@babel/plugin-transform-runtime": "^7.13.10",
"@babel/preset-env": "^7.13.12",
"@babel/preset-react": "7.18.6",
"@babel/runtime": "^7.13.10",
"@commitlint/cli": "^17.0.0",
"@commitlint/config-conventional": "^17.0.0",
"@erquhart/rollup-plugin-node-builtins": "^2.1.5",
"@fontsource/abel": "^4.5.7",
"@fontsource/raleway": "^4.5.11",
"@jscutlery/semver": "^2.29.3",
"@nx/webpack": "16.3.1",
"@reach/visually-hidden": "^0.1.2",
"@types/fs-extra": "^11.0.1",
"@types/glob": "^8.0.1",
"@types/jest": "29.4.4",
"@types/mustache": "^4.2.2",
"@types/node": "18.11.18",
"@types/nunjucks": "^3.2.1",
"@types/underscore": "^1.11.4",
"@typescript-eslint/eslint-plugin": "5.58.0",
"@typescript-eslint/parser": "5.58.0",
"auto": "^10.27.0",
"autoprefixer": "^10.2.5",
"babel-jest": "29.4.3",
"babel-loader": "^9.1.2",
"chokidar-cli": "^2.1.0",
"classnames": "^2.3.1",
"clean-css-loader": "^4.2.1",
"clean-webpack-plugin": "4.0.0",
"clipboard": "^2.0.8",
"copy-webpack-plugin": "^11.0.0",
"copyfiles": "^2.4.1",
"cross-env": "^5.2.0",
"css-loader": "^6.7.3",
"eslint": "~8.15.0",
"eslint-config-prettier": "8.1.0",
"eslint-plugin-prettier": "^3.1.0",
"fuse.js": "^6.4.6",
"handlebars": "^4.7.7",
"html-loader": "^4.2.0",
"html-webpack-plugin": "^5.5.0",
"husky": "^8.0.2",
"jest": "29.4.3",
"jest-environment-jsdom": "29.4.3",
"json-to-scss": "1.6.2",
"lit-element": "^2.2.1",
"lit-html": "^1.1.2",
"make-dir-cli": "^2.0.0",
"mini-css-extract-plugin": "^2.7.2",
"mousetrap": "^1.6.5",
"nx": "16.3.1",
"postcss": "^8.2.8",
"postcss-loader": "^7.0.2",
"preact": "^10.0.5",
"preload-webpack-plugin": "^3.0.0-beta.3",
"prettier": "^2.8.1",
"pretty": "^2.0.0",
"prismjs": "^1.25.0",
"pwa-helpers": "^0.9.1",
"react-autosuggest": "^9.4.2",
"react-dom": "^16.8.6",
"react-html-parser": "^2.0.2",
"redux": "4.1.2",
"redux-thunk": "^2.4.0",
"reflect-metadata": "0.1.13",
"rollup": "^1.16.1",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.0.3",
"sass-loader": "^13.2.0",
"scriptjs": "^2.5.9",
"scroll-js": "3.4.x",
"skatejs": "^5.2.4",
"style-loader": "^3.3.1",
"svg-sprite-loader": "^6.0.11",
"svg-transform-loader": "^2.0.13",
"svgo-loader": "^4.0.0",
"symlink-dir": "^5.1.1",
"ts-jest": "29.1.0",
"ts-loader": "^9.4.2",
"ts-node": "10.9.1",
"typescript": "5.0.4",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1",
"webpack-hot-middleware": "^2.25.3",
"webpack-merge": "^5.8.0",
"webpackbar": "5.0.2",
"wolfy87-eventemitter": "^5.2.9",
"yargs": "^17.0.1",
"@nx/workspace": "16.3.1",
"@nx/js": "16.3.1",
"@nx/eslint-plugin": "16.3.1",
"@nx/web": "16.3.1",
"@nx/linter": "16.3.1",
"@nx/jest": "16.3.1"
}
}
18 changes: 18 additions & 0 deletions packages/cli/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
3 changes: 0 additions & 3 deletions packages/cli/.gitattributes

This file was deleted.

81 changes: 0 additions & 81 deletions packages/cli/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions packages/cli/.npmrc

This file was deleted.

1 change: 0 additions & 1 deletion packages/cli/.nvmrc

This file was deleted.

11 changes: 0 additions & 11 deletions packages/cli/.travis.yml

This file was deleted.

71 changes: 68 additions & 3 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,72 @@
# Change Log
# Changelog

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## 1.0.0 (2023-02-11)


### ⚠ BREAKING CHANGES

* **cli:** previously, we concatenated arrays, which is unlikely to be intended
* **API:** change `version()` to return a string representation of the version, removing `v()`

### Features

* add nx workspace settings ([5bbee08](https://github.com/pattern-lab/patternlab-node/commit/5bbee082c4e0d2d8187fbd487827090baf010fbe))
* add release feature ([7f731c4](https://github.com/pattern-lab/patternlab-node/commit/7f731c4b56e663b57d71c7776c0c5e6424c1575e))
* **API:** standardize v() and version() into a single call ([6309e69](https://github.com/pattern-lab/patternlab-node/commit/6309e693b0971ea26c86e0e2b957ba413492e1b7))
* **cli:** if starterkit has pl config, deep merge it in ([cd91786](https://github.com/pattern-lab/patternlab-node/commit/cd9178675a906d9f1d46815233db70cd3ae258ac))
* **cli:** make options more user friendly ([ad845b3](https://github.com/pattern-lab/patternlab-node/commit/ad845b394ef81f90895ebb5bc6f12cc608e5e3d4))
* **cli:** Rename package ([9ea40d4](https://github.com/pattern-lab/patternlab-node/commit/9ea40d4a8f35247a3995ce20fad5e716b582ee10))
* move dev packages ([0136648](https://github.com/pattern-lab/patternlab-node/commit/0136648039233f82a608bd194f686bcf99159192))
* **package:** add npmrc file ([55f5bc2](https://github.com/pattern-lab/patternlab-node/commit/55f5bc26d635805648caa2d35d1bf306fe4740d5))
* **package:** pin all dependencies ([415698e](https://github.com/pattern-lab/patternlab-node/commit/415698eb9a70d477ffb7b2906e679ac8f2051c60))
* **package:** remove package-lock.json files ([5ab3995](https://github.com/pattern-lab/patternlab-node/commit/5ab399599a1dbea8239fbd09a34d5f39ad762e21))
* **package:** standardize and hoist common devDependencies ([7f4ce6f](https://github.com/pattern-lab/patternlab-node/commit/7f4ce6ff1238986bed906c27d2f4bf7329752d92))
* **README:** simplify README and add CLI configuration instructions ([ceec673](https://github.com/pattern-lab/patternlab-node/commit/ceec673b1a9b473949534a444b4334c48bcdf5cd))
* **serve:** change calling method ([3b86a0d](https://github.com/pattern-lab/patternlab-node/commit/3b86a0dbb29ec8842d49e2158bd0c6ace45fb86b))
* setup edition-twig in cli init ([480ed5d](https://github.com/pattern-lab/patternlab-node/commit/480ed5d14042a31d566d8d1107f7ca820ea18293))
* **starterkits:** add starterkit-handlebars-demo ([384d2cf](https://github.com/pattern-lab/patternlab-node/commit/384d2cfa3440c1e6f456d39f56ca6381f82f7689))
* **tests:** use lerna run test at the monorepo level ([38a01b1](https://github.com/pattern-lab/patternlab-node/commit/38a01b148a5356e2f8b30182e0453f6746347d96))
* update workspace settings ([39092c1](https://github.com/pattern-lab/patternlab-node/commit/39092c13ed91cfd2a6a51929d4bd612abc937038))


### Bug Fixes

* **cli:** add custom install logic to edition-node ([f04fd26](https://github.com/pattern-lab/patternlab-node/commit/f04fd266429cd806987dab747e6d69bff9b926a4))
* **cli:** allow any package to be installed as a starterkit ([d2aa1be](https://github.com/pattern-lab/patternlab-node/commit/d2aa1be810a0a7473dcc52391a2263dacfdda0b8)), closes [#1067](https://github.com/pattern-lab/patternlab-node/issues/1067)
* **cli:** change line-endings of cli entrypoint ([3fc86c2](https://github.com/pattern-lab/patternlab-node/commit/3fc86c29030189276baa655da02ff4ed68dcb80e))
* **cli:** change whitespace to spaces per standard ([4556fc7](https://github.com/pattern-lab/patternlab-node/commit/4556fc7d12a1d11b401821919ff2f3ddc5658c93))
* **cli:** do not call build before serve ([663d8e1](https://github.com/pattern-lab/patternlab-node/commit/663d8e185efd951ae67a37e3ec97f76d6cec0d5e)), closes [#917](https://github.com/pattern-lab/patternlab-node/issues/917)
* **cli:** ensure specified directory exists prior to scaffold ([cc3b696](https://github.com/pattern-lab/patternlab-node/commit/cc3b69624d486c94ee3b1f4b1bbb0334a514fa59))
* **cli:** fix test script glob ([ff18eb5](https://github.com/pattern-lab/patternlab-node/commit/ff18eb51ce24fc5423b009168e85ede366069139))
* **cli:** merge config arrays via overwrite instead of concatenate ([42e5f7b](https://github.com/pattern-lab/patternlab-node/commit/42e5f7b42a26b4fc1f262c68ee4b474b546f2eac))
* **cli:** pass watch options cleanly to core ([8bf186b](https://github.com/pattern-lab/patternlab-node/commit/8bf186b8e2ea2ea5ddcd2d6242b670275b65567f))
* **cli:** proper path resolution to helpers ([a18fe5e](https://github.com/pattern-lab/patternlab-node/commit/a18fe5ef4d1c074a5eba8bfa255ebbee2261bf74))
* **cli:** re-order and clarify engines ([e39e301](https://github.com/pattern-lab/patternlab-node/commit/e39e301a33306c6615fabf64262f1893ca682b97))
* **cli:** remove copy-source-files ([64311a1](https://github.com/pattern-lab/patternlab-node/commit/64311a155f82ddd86806087ad165b9ed880118f3)), closes [#833](https://github.com/pattern-lab/patternlab-node/issues/833)
* **cli:** run npm init -y if needed ([105e91c](https://github.com/pattern-lab/patternlab-node/commit/105e91ce08b4e8a21c5c53e95b0cd2d7287340fe))
* **cli:** set current working directory before scaffolded npm init ([6d2186d](https://github.com/pattern-lab/patternlab-node/commit/6d2186d8e8a74634198a4474ca8ae83221dd70a9))
* **cli:** set initialized to false during plugin installation ([88cce3f](https://github.com/pattern-lab/patternlab-node/commit/88cce3f9e91824f6650b1ea82eca950a480edf06))
* **cli:** support scoped plugins ([4ae13ce](https://github.com/pattern-lab/patternlab-node/commit/4ae13ce99ea17ffa0ab48a0f6370a5b70834d6d3))
* **config:** Add npm registry to lerna config ([1473cd5](https://github.com/pattern-lab/patternlab-node/commit/1473cd554c24b4c1baa4ee5ac59958f3499b9902))
* **install:** add break statements to install edition command ([3b1813c](https://github.com/pattern-lab/patternlab-node/commit/3b1813c53b65c64eb135dfb35b54ab513992521c))
* **install:** copy dependencies ([1acef87](https://github.com/pattern-lab/patternlab-node/commit/1acef874765d21e75a65a9b6cad0a0291822f804))
* **install:** use process to find package.json ([200c7cb](https://github.com/pattern-lab/patternlab-node/commit/200c7cb4f5e909d7ac88070f7ab6a07563b35f22))
* manually bump package.json versions of packages published in September but with mismatched package.json versions ([98dfadf](https://github.com/pattern-lab/patternlab-node/commit/98dfadf083eacc6741a8a8d4a79ef0cf869360d2))
* **nvmrc:** bump Node version ([36a917f](https://github.com/pattern-lab/patternlab-node/commit/36a917ff9cd75ff7645e054ff8ceba67371b927a))
* **package:** update publish config and installation target ([27d2c8f](https://github.com/pattern-lab/patternlab-node/commit/27d2c8f5cdcf2c6497af5016517c0a9c66b9972c))
* **package:** update tap dependency ([2b70ff4](https://github.com/pattern-lab/patternlab-node/commit/2b70ff4f2766d6dd8189c2db1f00d31a8d28e333))
* **plugin:** correct spelling error and function locations ([d4abd88](https://github.com/pattern-lab/patternlab-node/commit/d4abd88cb017550002407241b5045a2ad1adb1dc))
* **tests:** change test command name similar to live-server until this passes CI ([5c39be1](https://github.com/pattern-lab/patternlab-node/commit/5c39be1328f0533827f5de38286073367b9483df))
* updates to fix eslint / prettier issues; update packages/core to reuse root .eslintrc.js file ([5b7a057](https://github.com/pattern-lab/patternlab-node/commit/5b7a057d46ccd16b5832af1441030c7b76f237a8))
* **version:** use static core method getVersion ([f9dcd4d](https://github.com/pattern-lab/patternlab-node/commit/f9dcd4d4a8c1ab31202b4e723788c8fba72a059e))
* **wording:** reconcile Pattern Lab vs PatternLab ([f3d1e0d](https://github.com/pattern-lab/patternlab-node/commit/f3d1e0d807584ffbbbf2ea5869af7b916f25bbc8))


### Reverts

* Revert "[skip travis] chore(release): publish v5.10.0" ([7496318](https://github.com/pattern-lab/patternlab-node/commit/7496318e083f667b6da914e21595c52442d62703))

## [6.0.1](https://github.com/pattern-lab/patternlab-node/compare/v6.0.0...v6.0.1) (2023-02-01)

16 changes: 16 additions & 0 deletions packages/cli/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-disable */
export default {
displayName: 'cli',
preset: '../../jest.preset.js',
globals: {},
transform: {
'^.+\\.[tj]s$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
},
],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/packages/cli',
};
34 changes: 3 additions & 31 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -8,29 +8,6 @@
"author": {
"name": "Patternlab contributors"
},
"dependencies": {
"@pattern-lab/core": "^6.0.1",
"archiver": "5.3.0",
"chalk": "4.1.0",
"commander": "9.4.1",
"deepmerge": "^4.2.2",
"execa": "5.0.0",
"fs-extra": "10.0.0",
"glob": "7.1.6",
"has-yarn": "2.1.0",
"inquirer": "8.0.0",
"lodash": "4.17.21",
"ora": "5.4.0"
},
"devDependencies": {
"dos2unix-cli": "^1.0.1",
"eslint": "4.18.2",
"eslint-config-prettier": "2.9.0",
"eslint-plugin-prettier": "2.6.0",
"prettier": "2.8.1",
"proxyquire": "2.1.3",
"tap": "14.11.0"
},
"files": [
"bin"
],
@@ -40,19 +17,14 @@
"Node",
"JavaScript"
],
"scripts": {
"lint": "eslint ./{bin,test}",
"test:separate": "tap './test/*.test.js' --reporter spec --timeout=120",
"prepublish": "npx dos2unix-cli bin/patternlab.js"
},
"repository": "https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli",
"bugs": "https://github.com/pattern-lab/patternlab-node/issues",
"license": "MIT",
"devDependencies": {
"dos2unix-cli": "^1.0.1"
},
"engines": {
"node": ">=14.21.1"
},
"publishConfig": {
"access": "public"
},
"gitHead": "80f62be442223e09bafb30d0529cbd768e03f2ac"
}
55 changes: 55 additions & 0 deletions packages/cli/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "cli",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/cli/src",
"projectType": "library",
"implicitDependencies": ["core"],
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/cli",
"main": "packages/cli/bin/patternlab.ts",
"tsConfig": "packages/cli/tsconfig.lib.json",
"assets": ["packages/cli/*.md", "packages/cli/LICENSE"],
"buildableProjectDepsInPackageJsonType": "dependencies"
}
},
"publish": {
"executor": "nx:run-commands",
"options": {
"command": "node tools/scripts/publish.mjs cli {args.ver} {args.tag}"
},
"dependsOn": ["build"]
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/cli/**/*.ts"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/cli/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
},
"version": {
"executor": "@jscutlery/semver:version",
"options": {
"preset": "conventional"
}
}
},
"tags": []
}
17 changes: 15 additions & 2 deletions packages/cli/readme.md
Original file line number Diff line number Diff line change
@@ -5,14 +5,16 @@
[![Continuous Integration](https://github.com/pattern-lab/patternlab-node/actions/workflows/continuous-integration.yml/badge.svg?branch=dev)](https://github.com/pattern-lab/patternlab-node/actions/workflows/continuous-integration.yml)
[![CodeQL](https://github.com/pattern-lab/patternlab-node/actions/workflows/codeql-analysis.yml/badge.svg?branch=dev)](https://github.com/pattern-lab/patternlab-node/actions/workflows/codeql-analysis.yml)


## Installation
*Note: Global installs are currently not supported and will be fixed when the Pattern Lab core hits v3.0.0*

_Note: Global installs are currently not supported and will be fixed when the Pattern Lab core hits v3.0.0_

#### Via NPM

`npm install @pattern-lab/cli --save-dev`

#### Via Yarn

`yarn add @pattern-lab/cli --dev`

## Configuring Your Project to Use the CLI
@@ -28,6 +30,7 @@ Open `package.json` and add the following to your `scripts` object:
+ "patternlab": "patternlab"
},
```

This tells `npm` to look in the local `node_modules/.bin` directory for the `patternlab` CLI.

Subcommands and options can then be forwarded to the CLI like this:
@@ -55,7 +58,9 @@ npm run pl:serve
```

## API & Usage

### General usage

```
Usage: patternlab <cmd> [options]
Commands:
@@ -74,6 +79,7 @@ Usage: patternlab <cmd> [options]
```

### Build/Compile Pattern Lab

```
Usage: build|compile [options]
@@ -85,6 +91,7 @@ Build Pattern Lab. Optionally (re-)build only the patterns
```

### Initialize Pattern Lab

```
Usage: init [options]
@@ -99,6 +106,7 @@ Passing no options starts the init in interactive mode
```

### Serve Pattern Lab

```
Usage: serve|browse [options]
@@ -111,6 +119,7 @@ Starts a server to inspect files in browser
```

### Export Pattern Lab

```
Usage: export [options]
@@ -121,6 +130,7 @@ Export a Pattern Lab patterns into a compressed format
```

### Install Pattern Lab starterkits or plugins

```
Usage: install|add [options]
@@ -134,10 +144,13 @@ Installs Pattern Lab related modules like starterkits or plugins
```

## Examples

```
$ patternlab init # Initialize a Pattern Lab project.
$ patternlab build # Builds Pattern Lab from the current dir
$ patternlab build --config <path/to/patternlab-config> # Builds Pattern Lab from different project directory
```

## License

MIT © [Patternlab contributors](https://github.com/pattern-lab/patternlab-node/blob/master/CODEOWNERS)
45 changes: 0 additions & 45 deletions packages/cli/test/build.test.js

This file was deleted.

49 changes: 0 additions & 49 deletions packages/cli/test/cli-build.test.js

This file was deleted.

52 changes: 0 additions & 52 deletions packages/cli/test/cli-disable.test.js

This file was deleted.

45 changes: 0 additions & 45 deletions packages/cli/test/cli-enable.test.js

This file was deleted.

35 changes: 0 additions & 35 deletions packages/cli/test/cli-export.test.js

This file was deleted.

44 changes: 0 additions & 44 deletions packages/cli/test/cli-init.test.js

This file was deleted.

31 changes: 0 additions & 31 deletions packages/cli/test/export.test.js

This file was deleted.

97 changes: 0 additions & 97 deletions packages/cli/test/fixtures/patternlab-config.json

This file was deleted.

29 changes: 0 additions & 29 deletions packages/cli/test/install-plugin.test.js

This file was deleted.

48 changes: 0 additions & 48 deletions packages/cli/test/install-starterkit.test.js

This file was deleted.

15 changes: 0 additions & 15 deletions packages/cli/test/mocks/liverserver.mock.js

This file was deleted.

21 changes: 0 additions & 21 deletions packages/cli/test/mocks/patternlab.mock.js

This file was deleted.

44 changes: 0 additions & 44 deletions packages/cli/test/replace_config_paths.test.js

This file was deleted.

18 changes: 0 additions & 18 deletions packages/cli/test/resolve_config.test.js

This file was deleted.

31 changes: 0 additions & 31 deletions packages/cli/test/scaffold.test.js

This file was deleted.

51 changes: 0 additions & 51 deletions packages/cli/test/serve.test.js

This file was deleted.

6 changes: 0 additions & 6 deletions packages/cli/test/utils/getUniqueProjectPath.js

This file was deleted.

13 changes: 0 additions & 13 deletions packages/cli/test/utils/spawnCmd.js

This file was deleted.

23 changes: 23 additions & 0 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
10 changes: 10 additions & 0 deletions packages/cli/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"include": ["bin/**/*.ts", "bin/**/*.js"],
"exclude": ["jest.config.ts", "bin/**/*.spec.ts", "bin/**/*.test.ts", "bin/**/*.spec.js", "bin/**/*.test.js"]
}
9 changes: 9 additions & 0 deletions packages/cli/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
}
3 changes: 0 additions & 3 deletions packages/core/.eslintrc.js

This file was deleted.

18 changes: 18 additions & 0 deletions packages/core/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
2 changes: 0 additions & 2 deletions packages/core/.npmignore

This file was deleted.

2 changes: 0 additions & 2 deletions packages/core/.npmrc

This file was deleted.

1 change: 0 additions & 1 deletion packages/core/.nvmrc

This file was deleted.

125 changes: 122 additions & 3 deletions packages/core/CHANGELOG.md

Large diffs are not rendered by default.

25 changes: 13 additions & 12 deletions packages/core/LICENSE
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 Brian Muenzenmeyer, https://brianmuenzenmeyer.com & Brad Frost, https://bradfrost.com
Copyright Patternlab contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
17 changes: 17 additions & 0 deletions packages/core/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable */
module.exports = {
displayName: 'core',
preset: '../../jest.preset.js',
globals: {},
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
},
],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/packages/core',
};
42 changes: 1 addition & 41 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -2,39 +2,6 @@
"name": "@pattern-lab/core",
"description": "Create atomic design systems with Pattern Lab. This is the core API and orchestrator of the ecosystem.",
"version": "6.0.1",
"main": "./src/index.js",
"dependencies": {
"@pattern-lab/engine-handlebars": "^6.0.0",
"@pattern-lab/engine-mustache": "^6.0.0",
"@pattern-lab/live-server": "^6.0.0",
"chalk": "4.1.0",
"chokidar": "3.5.1",
"dive": "0.5.0",
"fs-extra": "10.0.0",
"glob": "7.1.6",
"graphlib": "2.1.8",
"js-beautify": "1.13.5",
"js-yaml": "4.1.0",
"lodash": "4.17.21",
"markdown-it": "12.3.2",
"node-fetch": "2.6.7",
"recursive-copy": "2.0.13",
"update-notifier": "5.1.0"
},
"devDependencies": {
"@babel/core": "^7.13.14",
"@babel/plugin-proposal-decorators": "^7.13.5",
"@babel/plugin-syntax-jsx": "^7.12.13",
"babel-eslint": "^10.0.2",
"eslint": "^6.1.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-prettier": "^3.1.0",
"jsdoc-to-markdown": "6.0.1",
"prettier": "^2.8.1",
"rewire": "2.5.2",
"standard-version": "9.1.1",
"tap": "14.11.0"
},
"keywords": [
"Pattern Lab",
"Atomic Web Design",
@@ -58,17 +25,10 @@
],
"license": "MIT",
"scripts": {
"docs": "node ./scripts/docs.js",
"lint": "eslint -c ../../.eslintrc.js src/**/*.js",
"pretest": "npm run lint",
"release": "standard-version",
"test": "tap test/*_tests.js --reporter spec --coverage"
"docs": "node ./scripts/docs.js"
},
"engines": {
"node": ">=14.21.1"
},
"publishConfig": {
"access": "public"
},
"gitHead": "80f62be442223e09bafb30d0529cbd768e03f2ac"
}
54 changes: 54 additions & 0 deletions packages/core/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "core",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/core/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/core",
"main": "packages/core/src/index.js",
"tsConfig": "packages/core/tsconfig.lib.json",
"assets": ["packages/core/*.md", "packages/core/LICENSE", "packages/core/patternlab-config.json"],
"buildableProjectDepsInPackageJsonType": "dependencies"
}
},
"publish": {
"executor": "nx:run-commands",
"options": {
"command": "node tools/scripts/publish.mjs core {args.ver} {args.tag}"
},
"dependsOn": ["build"]
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/core/**/*.js"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/core/jest.config.js",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
},
"version": {
"executor": "@jscutlery/semver:version",
"options": {
"preset": "conventional"
}
}
},
"tags": []
}
32 changes: 7 additions & 25 deletions packages/core/src/index.js
Original file line number Diff line number Diff line change
@@ -8,8 +8,6 @@
* @license MIT
*/

'use strict';

const updateNotifier = require('update-notifier');

const packageInfo = require('../package.json');
@@ -123,18 +121,12 @@ const patternlab_module = function (config) {
// });

if (patternlab && patternlab.isBusy) {
logger.info(
'Pattern Lab is busy building a previous run - returning early.'
);
logger.info('Pattern Lab is busy building a previous run - returning early.');
return Promise.resolve();
}
patternlab.isBusy = true;

return await buildPatterns(
options.cleanPublic,
patternlab,
options.data
).then(() => {
return await buildPatterns(options.cleanPublic, patternlab, options.data).then(() => {
return new ui_builder().buildFrontend(patternlab).then(() => {
copier()
.copyAndWatch(patternlab.config.paths, patternlab, options)
@@ -144,9 +136,7 @@ const patternlab_module = function (config) {
// figure out how to detect if serve was called. we should not assume it was
if (
patternlab.serverReady //check for server presence
? this.events.listenerCount(
events.PATTERNLAB_PATTERN_CHANGE
) === 1 //if the server is started, it has already setup one listener
? this.events.listenerCount(events.PATTERNLAB_PATTERN_CHANGE) === 1 //if the server is started, it has already setup one listener
: !this.events.listenerCount(events.PATTERNLAB_PATTERN_CHANGE) // else, check for the presnce of none
) {
this.events.on(events.PATTERNLAB_PATTERN_CHANGE, () => {
@@ -163,7 +153,7 @@ const patternlab_module = function (config) {
this.events.on(events.PATTERNLAB_GLOBAL_CHANGE, () => {
if (!patternlab.isBusy) {
return this.build(
Object.assign({}, options, { cleanPublic: true }) // rebuild everything
Object.assign({}, options, { cleanPublic: true }), // rebuild everything
);
}
return Promise.resolve();
@@ -240,17 +230,11 @@ const patternlab_module = function (config) {
*/
patternsonly: async function (options) {
if (patternlab && patternlab.isBusy) {
logger.info(
'Pattern Lab is busy building a previous run - returning early.'
);
logger.info('Pattern Lab is busy building a previous run - returning early.');
return Promise.resolve();
}
patternlab.isBusy = true;
return await buildPatterns(
options.cleanPublic,
patternlab,
options.data
).then(() => {
return await buildPatterns(options.cleanPublic, patternlab, options.data).then(() => {
patternlab.isBusy = false;
});
},
@@ -277,9 +261,7 @@ const patternlab_module = function (config) {
return _api
.build(options)
.then(() => server.serve())
.catch((e) =>
logger.error(`error inside core index.js server serve: ${e}`)
);
.catch((e) => logger.error(`error inside core index.js server serve: ${e}`));
},
/**
* Reloads any active live-server instances
37 changes: 9 additions & 28 deletions packages/core/src/lib/copier.js
Original file line number Diff line number Diff line change
@@ -11,15 +11,7 @@ const copier = () => {
const transform_paths = (directories) => {
//create array with all source keys minus our blacklist
const dirs = {};
const blackList = [
'root',
'patterns',
'data',
'meta',
'annotations',
'patternlabFiles',
'styleguide',
];
const blackList = ['root', 'patterns', 'data', 'meta', 'annotations', 'patternlabFiles', 'styleguide'];
_.each(directories.source, (dir, key) => {
if (blackList.includes(key)) {
return;
@@ -57,10 +49,7 @@ const copier = () => {

// Adding assets to filter for in case of transformedAssetTypes defined; adapted regex from https://stackoverflow.com/a/6745455
if (patternlab.config.transformedAssetTypes) {
copyOptions.filter = new RegExp(
`.*(?<![.](${patternlab.config.transformedAssetTypes.join('|')}))$`,
'i'
);
copyOptions.filter = new RegExp(`.*(?<![.](${patternlab.config.transformedAssetTypes.join('|')}))$`, 'i');
}

//loop through each directory asset object (source / public pairing)
@@ -75,12 +64,8 @@ const copier = () => {
//just copy
copyPromises.push(
_.map(patternlab.uikits, (uikit) => {
copyFile(
dir.source,
path.join(basePath, uikit.outputDir, dir.public),
copyOptions
);
})
copyFile(dir.source, path.join(basePath, uikit.outputDir, dir.public), copyOptions);
}),
);
}
});
@@ -91,24 +76,20 @@ const copier = () => {
copyFile(
path.join(uikit.modulePath, assetDirectories.source.styleguide),
path.join(basePath, uikit.outputDir, assetDirectories.public.root),
copyOptions
copyOptions,
);
})
}),
);

// copy the favicon
copyPromises.push(
_.map(patternlab.uikits, (uikit) => {
copyFile(
`${assetDirectories.source.root}favicon.ico`,
path.join(
basePath,
uikit.outputDir,
`${assetDirectories.public.root}/favicon.ico`
),
copyOptions
path.join(basePath, uikit.outputDir, `${assetDirectories.public.root}/favicon.ico`),
copyOptions,
);
})
}),
);

return Promise.all(copyPromises).then(() => {
50 changes: 13 additions & 37 deletions packages/core/src/lib/exportData.js
Original file line number Diff line number Diff line change
@@ -24,10 +24,7 @@ module.exports = function (patternlab, uikit) {

//ishControls
output +=
'var ishControls = {"ishControlsHide":' +
JSON.stringify(patternlab.config.ishControlsHide) +
'};' +
eol;
'var ishControls = {"ishControlsHide":' + JSON.stringify(patternlab.config.ishControlsHide) + '};' + eol;

//navItems
output +=
@@ -39,47 +36,32 @@ module.exports = function (patternlab, uikit) {
eol;

//patternPaths
output +=
'var patternPaths = ' + JSON.stringify(patternlab.patternPaths) + ';' + eol;
output += 'var patternPaths = ' + JSON.stringify(patternlab.patternPaths) + ';' + eol;

//viewAllPaths
output +=
'var viewAllPaths = ' + JSON.stringify(patternlab.viewAllPaths) + ';' + eol;
output += 'var viewAllPaths = ' + JSON.stringify(patternlab.viewAllPaths) + ';' + eol;

//plugins
output +=
'var plugins = ' + JSON.stringify(patternlab.plugins || []) + ';' + eol;
output += 'var plugins = ' + JSON.stringify(patternlab.plugins || []) + ';' + eol;

//smaller config elements
output +=
'var defaultShowPatternInfo = ' +
(patternlab.config.defaultShowPatternInfo
? patternlab.config.defaultShowPatternInfo
: 'false') +
(patternlab.config.defaultShowPatternInfo ? patternlab.config.defaultShowPatternInfo : 'false') +
';' +
eol;
output +=
'var defaultPattern = "' +
(patternlab.config.defaultPattern
? patternlab.config.defaultPattern
: 'all') +
(patternlab.config.defaultPattern ? patternlab.config.defaultPattern : 'all') +
'";' +
eol;

//annotations
const annotationsJSON = annotationExporter.gather();
const annotations =
'var comments = { "comments" : ' + JSON.stringify(annotationsJSON) + '};';
const annotations = 'var comments = { "comments": ' + JSON.stringify(annotationsJSON) + '};';
fs.outputFileSync(
path.resolve(
path.join(
process.cwd(),
uikit.outputDir,
paths.public.annotations,
'annotations.js'
)
),
annotations
path.resolve(path.join(process.cwd(), uikit.outputDir, paths.public.annotations, 'annotations.js')),
annotations,
);

// add module.export to the Nodejs-specific file generated.
@@ -89,18 +71,12 @@ module.exports = function (patternlab, uikit) {

//write all output to patternlab-data
fs.outputFileSync(
path.resolve(
path.join(process.cwd(), uikit.outputDir, paths.public.data),
'patternlab-data.js'
),
output
path.resolve(path.join(process.cwd(), uikit.outputDir, paths.public.data), 'patternlab-data.js'),
output,
);
fs.outputFileSync(
path.resolve(
path.join(process.cwd(), uikit.outputDir, paths.public.data),
'patternlab-data.cjs.js'
),
exportedOutput
path.resolve(path.join(process.cwd(), uikit.outputDir, paths.public.data), 'patternlab-data.cjs.js'),
exportedOutput,
);

return output;
53 changes: 19 additions & 34 deletions packages/core/src/lib/loadPattern.js
Original file line number Diff line number Diff line change
@@ -19,6 +19,12 @@ let fs = require('fs-extra'); //eslint-disable-line prefer-const

// loads a pattern from disk, creates a Pattern object from it and
// all its associated files, and records it in patternlab.patterns[]
/**
* @type Class
* @param {*} relPath
* @param {*} patternlab
* @returns
*/
module.exports = function (relPath, patternlab) {
const fileObject = path.parse(relPath);

@@ -42,25 +48,17 @@ module.exports = function (relPath, patternlab) {
relPath +
' was found greater than 3 levels deep from ' +
patternlab.config.paths.source.patterns +
'.'
);
logger.warning(
"It's strongly suggested to not deviate from the following structure under _patterns/"
);
logger.warning(
'[patternGroup]/[patternSubgroup]/[patternName].[patternExtension]'
'.',
);
logger.warning("It's strongly suggested to not deviate from the following structure under _patterns/");
logger.warning('[patternGroup]/[patternSubgroup]/[patternName].[patternExtension]');
logger.warning('or');
logger.warning(
'[patternGroup]/[patternSubgroup]/[patternName]/[patternName].[patternExtension]'
);
logger.warning('[patternGroup]/[patternSubgroup]/[patternName]/[patternName].[patternExtension]');
logger.warning('');
logger.warning(
'While Pattern Lab may still function, assets may 404 and frontend links may break. Consider yourself warned. '
);
logger.warning(
'Read More: https://patternlab.io/docs/overview-of-patterns/'
'While Pattern Lab may still function, assets may 404 and frontend links may break. Consider yourself warned. ',
);
logger.warning('Read More: https://patternlab.io/docs/overview-of-patterns/');
logger.warning('');
}

@@ -80,23 +78,15 @@ module.exports = function (relPath, patternlab) {
//look for a json file for this template
let jsonFilename;
try {
jsonFilename = path.resolve(
patternsPath,
currentPattern.subdir,
currentPattern.fileName
);
jsonFilename = path.resolve(patternsPath, currentPattern.subdir, currentPattern.fileName);
const patternData = dataLoader.loadDataFromFile(jsonFilename, fs);

if (patternData) {
currentPattern.jsonFileData = patternData;
logger.debug(
`found pattern-specific data for ${currentPattern.patternPartial}`
);
logger.debug(`found pattern-specific data for ${currentPattern.patternPartial}`);
}
} catch (err) {
logger.error(
`There was an error parsing sibling JSON for ${currentPattern.relPath}`
);
logger.error(`There was an error parsing sibling JSON for ${currentPattern.relPath}`);
logger.error(err);
}

@@ -106,21 +96,17 @@ module.exports = function (relPath, patternlab) {
listJsonFileName = path.resolve(
patternsPath,
currentPattern.subdir,
`${currentPattern.fileName}.listitems`
`${currentPattern.fileName}.listitems`,
);
const listItemsData = dataLoader.loadDataFromFile(listJsonFileName, fs);

if (listItemsData) {
logger.debug(
`found pattern-specific listitems data for ${currentPattern.patternPartial}`
);
logger.debug(`found pattern-specific listitems data for ${currentPattern.patternPartial}`);
currentPattern.listitems = listItemsData;
buildListItems(currentPattern);
}
} catch (err) {
logger.error(
`There was an error parsing sibling listitem JSON for ${currentPattern.relPath}`
);
logger.error(`There was an error parsing sibling listitem JSON for ${currentPattern.relPath}`);
logger.error(err);
}

@@ -133,8 +119,7 @@ module.exports = function (relPath, patternlab) {
currentPattern.template = fs.readFileSync(templatePath, 'utf8');

//find any pattern parameters that may be in the current pattern
currentPattern.parameteredPartials =
currentPattern.findPartialsWithPatternParameters();
currentPattern.parameteredPartials = currentPattern.findPartialsWithPatternParameters();

[
templatePath,
1 change: 1 addition & 0 deletions packages/core/src/lib/loadPatternGraph.js
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ const PatternGraph = require('./pattern_graph').PatternGraph;
* For that reason an empty graph is returned in this case, so every pattern will be flagged as
* "needs recompile". Otherwise the pattern graph is loaded from the meta data.
*
* @type Class
* @param patternlab
* @param {boolean} deletePatternDir When {@code true}, an empty graph is returned
* @return {PatternGraph}
57 changes: 15 additions & 42 deletions packages/core/src/lib/object_factory.js
Original file line number Diff line number Diff line change
@@ -22,17 +22,13 @@ const prefixMatcherDeprecationCheckHidden = /^_.+/;
* https://github.com/pattern-lab/patternlab-node/pull/1016
* https://github.com/pattern-lab/patternlab-node/pull/1143
*
* @type Class
* @param {string} relPath relative directory
* @param {Object} jsonFileData The JSON used to render values in the pattern.
* @param {Patternlab} patternlab The actual pattern lab instance
* @param {boolean} isPromoteToFlatPatternRun specifies if the pattern needs to be removed from its deep nesting folder
*/
const Pattern = function (
relPath,
jsonFileData,
patternlab,
isPromoteToFlatPatternRun
) {
export const Pattern = function (relPath, jsonFileData, patternlab, isPromoteToFlatPatternRun) {
this.relPath = path.normalize(relPath); // 'atoms/global/colors.mustache'

/**
@@ -45,9 +41,7 @@ const Pattern = function (
pathObj,
patternlab,
isPromoteToFlatPatternRun ||
(patternlab &&
patternlab.config &&
patternlab.config.allPatternsAreDeeplyNested)
(patternlab && patternlab.config && patternlab.config.allPatternsAreDeeplyNested),
);

this.fileName = pathObj.name; // 'colors'
@@ -65,7 +59,7 @@ const Pattern = function (
!patternlab.config.disableDeprecationWarningForOrderPatterns
) {
logger.warning(
`${info.shortNotation}-${this.fileName} "Pattern", "Group" and "Subgroup" ordering by number prefix (##-) will be deprecated in the future.\n See https://patternlab.io/docs/reorganizing-patterns/`
`${info.shortNotation}-${this.fileName} "Pattern", "Group" and "Subgroup" ordering by number prefix (##-) will be deprecated in the future.\n See https://patternlab.io/docs/reorganizing-patterns/`,
);
}

@@ -79,7 +73,7 @@ const Pattern = function (
!patternlab.config.disableDeprecationWarningForHiddenPatterns
) {
logger.warning(
`${info.shortNotation}/${this.fileName} "Pattern", "Group" and "Subgroup" hiding by underscore prefix (_*) will be deprecated in the future.\n See https://patternlab.io/docs/hiding-patterns-in-the-navigation/`
`${info.shortNotation}/${this.fileName} "Pattern", "Group" and "Subgroup" hiding by underscore prefix (_*) will be deprecated in the future.\n See https://patternlab.io/docs/hiding-patterns-in-the-navigation/`,
);
}

@@ -101,9 +95,7 @@ const Pattern = function (
this.jsonFileData = jsonFileData || {};

// flip tildes to dashes
this.patternBaseName = this.fileName
.replace(prefixMatcher, '')
.replace('~', '-'); // 'colors'
this.patternBaseName = this.fileName.replace(prefixMatcher, '').replace('~', '-'); // 'colors'

// Fancy name - Uppercase letters of pattern name partials.
// global-colors -> 'Global Colors'
@@ -121,9 +113,7 @@ const Pattern = function (

// Calculated path from the root of the public directory to the generated
// (rendered!) html file for this pattern, to be shown in the iframe
this.patternLink = patternlab
? this.getPatternLink(patternlab, 'rendered')
: null;
this.patternLink = patternlab ? this.getPatternLink(patternlab, 'rendered') : null;

// The canonical "key" by which this pattern is known. This is the callable
// name of the pattern. UPDATE: this.key is now known as this.patternPartial
@@ -145,8 +135,7 @@ const Pattern = function (
* molecules
* flatPattern
*/
this.isFlatPattern =
this.patternGroup === this.patternSubgroup || !this.patternSubgroup;
this.isFlatPattern = this.patternGroup === this.patternSubgroup || !this.patternSubgroup;

this.isPattern = true;
this.patternState = '';
@@ -207,11 +196,7 @@ Pattern.prototype = {
}

if (this.engine) {
const promise = this.engine.renderPattern(
this,
data || this.jsonFileData,
partials
);
const promise = this.engine.renderPattern(this, data || this.jsonFileData, partials);
return promise
.then((results) => {
return results;
@@ -242,9 +227,7 @@ Pattern.prototype = {
getPatternLink: function (patternlab, suffixType, customFileExtension) {
// if no suffixType is provided, we default to rendered
const suffixConfig = patternlab.config.outputFileSuffixes;
const suffix = suffixType
? suffixConfig[suffixType]
: suffixConfig.rendered;
const suffix = suffixType ? suffixConfig[suffixType] : suffixConfig.rendered;

if (suffixType === 'rawTemplate') {
return this.name + path.sep + this.name + suffix + this.fileExtension;
@@ -346,8 +329,7 @@ Pattern.prototype = {
// colors(.mustache) is deeply nested in atoms-/global/colors
patternlab: patternlab,
patternHasOwnDir: isPromoteToFlatPatternRun
? path.basename(pathObj.dir).replace(prefixMatcher, '') ===
pathObj.name.replace(prefixMatcher, '') ||
? path.basename(pathObj.dir).replace(prefixMatcher, '') === pathObj.name.replace(prefixMatcher, '') ||
path.basename(pathObj.dir).replace(prefixMatcher, '') ===
pathObj.name.split('~')[0].replace(prefixMatcher, '')
: false,
@@ -367,24 +349,20 @@ Pattern.prototype = {
} else if (info.dirLevel === 2 && info.patternHasOwnDir) {
// -> ./folder
info.shortNotation = path.dirname(pathObj.dir).replace(prefixMatcher, '');
info.patternGroupOrder = Pattern.prototype.setPatternOrderDataForInfo(
path.dirname(pathObj.dir)
);
info.patternGroupOrder = Pattern.prototype.setPatternOrderDataForInfo(path.dirname(pathObj.dir));
} else {
// -> ./folder/folder
info.shortNotation = pathObj.dir
.split(/\/|\\/, 2)
.map((o, i) => {
if (i === 0) {
// TODO: Remove when prefix gets deprecated
info.patternGroupOrder =
Pattern.prototype.setPatternOrderDataForInfo(o);
info.patternGroupOrder = Pattern.prototype.setPatternOrderDataForInfo(o);
}

if (i === 1) {
// TODO: Remove when prefix gets deprecated
info.patternSubgroupOrder =
Pattern.prototype.setPatternOrderDataForInfo(o);
info.patternSubgroupOrder = Pattern.prototype.setPatternOrderDataForInfo(o);
}

return o.replace(prefixMatcher, '');
@@ -435,13 +413,8 @@ Pattern.create = function (relPath, data, customProps, patternlab) {
return Object.assign(newPattern, customProps);
};

const CompileState = {
export const CompileState = {
NEEDS_REBUILD: 'needs rebuild',
BUILDING: 'building',
CLEAN: 'clean',
};

module.exports = {
Pattern: Pattern,
CompileState: CompileState,
};
46 changes: 18 additions & 28 deletions packages/core/src/lib/pattern_engines.js
Original file line number Diff line number Diff line change
@@ -67,10 +67,10 @@ function findEnginesInConfig(config) {
return config.engines;
}
logger.warning(
"Scanning the 'node_modules' folder for pattern engines is deprecated and will be removed in v7."
"Scanning the 'node_modules' folder for pattern engines is deprecated and will be removed in v7.",
);
logger.warning(
'To configure your engines in patternlab-config.json, see https://patternlab.io/docs/editing-the-configuration-options/#heading-engines'
'To configure your engines in patternlab-config.json, see https://patternlab.io/docs/editing-the-configuration-options/#heading-engines',
);
return null;
}
@@ -106,10 +106,8 @@ const PatternEngines = Object.create({
// Quick fix until we've removed @pattern-lab/engine-mustache, starting with https://github.com/pattern-lab/patternlab-node/issues/1239 & https://github.com/pattern-lab/patternlab-node/pull/1455
// @TODO: Remove after removing @pattern-lab/engine-mustache dependency
enginesInConfig.mustache = enginesInConfig.mustache || {};
enginesInConfig.mustache.package =
enginesInConfig.mustache.package || '@pattern-lab/engine-mustache';
enginesInConfig.mustache.extensions =
enginesInConfig.mustache.extensions || 'mustache';
enginesInConfig.mustache.package = enginesInConfig.mustache.package || '@pattern-lab/engine-mustache';
enginesInConfig.mustache.extensions = enginesInConfig.mustache.extensions || 'mustache';

// Try loading each of the configured pattern engines
// eslint-disable-next-line guard-for-in
@@ -127,7 +125,9 @@ const PatternEngines = Object.create({
throw new Error('already loaded, skipping.');
}
if ('package' in engineConfig) {
self[name] = require(engineConfig.package);
const Engine = require(engineConfig.package).default;
const engine = new Engine();
self[name] = engine;
if (typeof self[name].usePatternLabConfig === 'function') {
self[name].usePatternLabConfig(patternLabConfig);
}
@@ -136,7 +136,7 @@ const PatternEngines = Object.create({
}
} else {
logger.warning(
`Engine ${name} not configured correctly. Please configure your engines in patternlab-config.json as documented in https://patternlab.io/docs/editing-the-configuration-options/#heading-engines`
`Engine ${name} not configured correctly. Please configure your engines in patternlab-config.json as documented in https://patternlab.io/docs/editing-the-configuration-options/#heading-engines`,
);
}
} catch (err) {
@@ -146,17 +146,15 @@ const PatternEngines = Object.create({
logger.info(
`Pattern Engine ${name} / package ${engineConfig.package}: ${
errorMessage ? errorMessage : successMessage
}`
}`,
);
}
}
} else {
// Try to load engines! We scan for engines at each path specified above. This
// function is kind of a big deal.
enginesDirectories.forEach(function (engineDirectory) {
const enginesInThisDir = findEngineModulesInDirectory(
engineDirectory.path
);
const enginesInThisDir = findEngineModulesInDirectory(engineDirectory.path);

`Loading engines from ${engineDirectory.displayName}: ${engineDirectory.path} ...`;

@@ -174,11 +172,10 @@ const PatternEngines = Object.create({
if (self[engineDiscovery.name]) {
throw new Error('already loaded, skipping.');
}
self[engineDiscovery.name] = require(engineDiscovery.modulePath);
if (
typeof self[engineDiscovery.name].usePatternLabConfig ===
'function'
) {
const Engine = require(engineDiscovery.modulePath).default;
const engine = new Engine();
self[engineDiscovery.name] = engine;
if (typeof self[engineDiscovery.name].usePatternLabConfig === 'function') {
self[engineDiscovery.name].usePatternLabConfig(patternLabConfig);
}
if (typeof self[engineDiscovery.name].spawnMeta === 'function') {
@@ -189,11 +186,9 @@ const PatternEngines = Object.create({
} finally {
// report on the status of the engine, one way or another!
logger.info(
`Pattern Engine ${
engineDiscovery.name
} by discovery (deprecated): ${
`Pattern Engine ${engineDiscovery.name} by discovery (deprecated): ${
errorMessage ? errorMessage : successMessage
}`
}`,
);
}
});
@@ -216,11 +211,7 @@ const PatternEngines = Object.create({
getEngineNameForPattern: function (pattern) {
// avoid circular dependency by putting this in here. TODO: is this slow?
const of = require('./object_factory');
if (
pattern instanceof of.Pattern &&
typeof pattern.fileExtension === 'string' &&
pattern.fileExtension
) {
if (pattern instanceof of.Pattern && typeof pattern.fileExtension === 'string' && pattern.fileExtension) {
//loop through known engines and find the one that supports the pattern's fileExtension
const engineNames = Object.keys(this);
for (let i = 0; i < engineNames.length; i++) {
@@ -315,8 +306,7 @@ const PatternEngines = Object.create({
}

// not a hidden pattern, let's dig deeper
const supportedPatternFileExtensions =
PatternEngines.getSupportedFileExtensions();
const supportedPatternFileExtensions = PatternEngines.getSupportedFileExtensions();
return (
supportedPatternFileExtensions.lastIndexOf(extension) !== -1 ||
PatternEngines.isPseudoPatternJSON(filename)
10 changes: 3 additions & 7 deletions packages/core/src/lib/pattern_graph.js
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ const PATTERN_GRAPH_VERSION = 1;
*
* @constructor Constructs a new PatternGraph from a JSON-style JavaScript object or an empty graph
* if no argument is given.
* @type Class
*
* @param {Graph} graph The graphlib graph object
* @param {int} timestamp The unix timestamp
@@ -173,9 +174,7 @@ PatternGraph.prototype = {
});

const nodes = this.graph.nodes();
const changedNodes = nodes.filter((n) =>
compileStateFilter(this.patterns, n)
);
const changedNodes = nodes.filter((n) => compileStateFilter(this.patterns, n));
this.nodes2patterns(changedNodes).forEach((pattern) => {
const patternNode = nodeName(pattern);
if (!compileGraph.hasNode(patternNode)) {
@@ -360,10 +359,7 @@ PatternGraph.fromJson = function (o) {
* @param {string} [fileName='dependencyGraph.json'] Name of the graph file
* @return {string}
*/
PatternGraph.resolveJsonGraphFile = function (
filePath = process.cwd(),
fileName = 'dependencyGraph.json'
) {
PatternGraph.resolveJsonGraphFile = function (filePath = process.cwd(), fileName = 'dependencyGraph.json') {
return path.resolve(filePath, fileName);
};

45 changes: 13 additions & 32 deletions packages/core/src/lib/pseudopattern_hunter.js
Original file line number Diff line number Diff line change
@@ -15,21 +15,17 @@ const changes_hunter = new ch();
const yaml = require('js-yaml');
const dataMerger = require('./dataMerger');

/**
* @type Class
*/
const pseudopattern_hunter = function () {};

pseudopattern_hunter.prototype.find_pseudopatterns = function (
currentPattern,
patternlab
) {
pseudopattern_hunter.prototype.find_pseudopatterns = function (currentPattern, patternlab) {
const paths = patternlab.config.paths;

//look for a pseudo pattern by checking if there is a file containing same
//name, with ~ in it, ending in .json, .yml or .yaml
const needle =
currentPattern.subdir +
'/' +
currentPattern.fileName +
'~*.{json,yml,yaml}';
const needle = currentPattern.subdir + '/' + currentPattern.fileName + '~*.{json,yml,yaml}';
const pseudoPatterns = glob.sync(needle, {
cwd: paths.source.patterns,
debug: false,
@@ -38,42 +34,27 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function (

if (pseudoPatterns.length > 0) {
for (let i = 0; i < pseudoPatterns.length; i++) {
logger.debug(
`Found pseudoPattern variant of ${currentPattern.patternPartial}`
);
logger.debug(`Found pseudoPattern variant of ${currentPattern.patternPartial}`);

//we want to do everything we normally would here, except instead read the pseudoPattern data
let variantFileFullPath;
let variantFileData;
try {
variantFileFullPath = path.resolve(
paths.source.patterns,
pseudoPatterns[i]
);
variantFileData = yaml.load(
fs.readFileSync(variantFileFullPath, 'utf8')
);
variantFileFullPath = path.resolve(paths.source.patterns, pseudoPatterns[i]);
variantFileData = yaml.load(fs.readFileSync(variantFileFullPath, 'utf8'));
} catch (err) {
logger.error(
`There was an error parsing pseudopattern JSON for ${currentPattern.relPath}`
);
logger.error(`There was an error parsing pseudopattern JSON for ${currentPattern.relPath}`);
logger.error(err);
}

//extend any existing data with variant data
variantFileData = dataMerger(
currentPattern.jsonFileData,
variantFileData,
patternlab.config
);
variantFileData = dataMerger(currentPattern.jsonFileData, variantFileData, patternlab.config);

const variantName = pseudoPatterns[i]
.substring(pseudoPatterns[i].indexOf('~') + 1)
.split('.')[0];
const variantName = pseudoPatterns[i].substring(pseudoPatterns[i].indexOf('~') + 1).split('.')[0];
const variantExtension = pseudoPatterns[i].split('.').slice(-1).pop();
const variantFilePath = path.join(
currentPattern.subdir,
currentPattern.fileName + '~' + variantName + '.' + variantExtension
currentPattern.fileName + '~' + variantName + '.' + variantExtension,
);
const lm = fs.statSync(variantFileFullPath);
const patternVariant = Pattern.create(
@@ -95,7 +76,7 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function (
// use the same template engine as the non-variant
engine: currentPattern.engine,
},
patternlab
patternlab,
);
patternVariant.order = _.clone(currentPattern.order);
patternVariant.hidden = _.clone(currentPattern.hidden);
23 changes: 23 additions & 0 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
10 changes: 10 additions & 0 deletions packages/core/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"include": ["src/**/*.ts", "src/**/*.js"],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.js", "src/**/*.test.js"]
}
9 changes: 9 additions & 0 deletions packages/core/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
}
18 changes: 18 additions & 0 deletions packages/create/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 Pattern Lab
Copyright Patternlab contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
2 changes: 1 addition & 1 deletion packages/create/README.md
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ To get started, simply run:
npm create pattern-lab
```

Then follow the prompts.
Then follow the prompts.

This is the same as using the main Pattern Lab CLI's `init` command:

16 changes: 16 additions & 0 deletions packages/create/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-disable */
export default {
displayName: 'create',
preset: '../../jest.preset.js',
globals: {},
transform: {
'^.+\\.[tj]s$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
},
],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/packages/create',
};
10 changes: 1 addition & 9 deletions packages/create/package.json
Original file line number Diff line number Diff line change
@@ -2,17 +2,9 @@
"name": "create-pattern-lab",
"version": "6.0.1",
"description": "",
"bin": "index.js",
"main": "index.js",
"scripts": {},
"dependencies": {
"@pattern-lab/cli": "^6.0.1"
},
"bin": "src/index.js",
"author": "",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"gitHead": "80f62be442223e09bafb30d0529cbd768e03f2ac",
"engines": {
"node": ">=14.21.1"
55 changes: 55 additions & 0 deletions packages/create/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "create",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/create/src",
"projectType": "library",
"implicitDependencies": ["cli"],
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/create",
"main": "packages/create/src/index.js",
"tsConfig": "packages/create/tsconfig.lib.json",
"assets": ["packages/create/*.md", "packages/create/LICENSE"],
"buildableProjectDepsInPackageJsonType": "dependencies"
}
},
"publish": {
"executor": "nx:run-commands",
"options": {
"command": "node tools/scripts/publish.mjs create {args.ver} {args.tag}"
},
"dependsOn": ["build"]
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/create/**/*.ts"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/create/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
},
"version": {
"executor": "@jscutlery/semver:version",
"options": {
"preset": "conventional"
}
}
},
"tags": []
}
File renamed without changes.
23 changes: 23 additions & 0 deletions packages/create/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
10 changes: 10 additions & 0 deletions packages/create/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"include": ["src/**/*.ts", "src/**/*.js"],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.js", "src/**/*.test.js"]
}
9 changes: 9 additions & 0 deletions packages/create/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
}
2 changes: 1 addition & 1 deletion packages/development-edition-engine-handlebars/.gitignore
Original file line number Diff line number Diff line change
@@ -7,4 +7,4 @@ Thumbs.db
.idea/
public
dependencyGraph.json
source/*
source
2 changes: 0 additions & 2 deletions packages/development-edition-engine-handlebars/.npmrc

This file was deleted.

1 change: 0 additions & 1 deletion packages/development-edition-engine-handlebars/.nvmrc

This file was deleted.

Loading