Skip to content

Commit

Permalink
chore(pie-monorepo): DSW-000 rename pie-git-hooks to @justeattakeaway…
Browse files Browse the repository at this point in the history
…/pie-monorepo-utils & update component status logic (#2034)

* attempt to fix env var v2

* refactor(pie-monorepo): WCP-000 component-status updates trigger  pie-docs / pie-storybook

* revert file

* revert file

* rebase

* remove file

* remove file

* update yarn.lock

* pr suggestions

* fix dist

* fix turbo config

* fix turbo config

* update yarn.lock

* pr suggestions

* remove old changelog

---------

Co-authored-by: Ben Siggery <ben.siggery@justeattakeaway.com>
  • Loading branch information
siggerzz and Ben Siggery authored Nov 14, 2024
1 parent 766b1f2 commit 8c43af8
Show file tree
Hide file tree
Showing 31 changed files with 2,067 additions and 1,758 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-poets-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"pie-monorepo": minor
---

[Removed] - @babel/traverse resolution to fix issue with pie-icons-webc build
6 changes: 6 additions & 0 deletions .changeset/neat-timers-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"pie-storybook": minor
"pie-docs": minor
---

[Added] - Refactor to use @justeattakeaway/pie-monorepo-utils to import component statuses
10 changes: 10 additions & 0 deletions .changeset/spotty-numbers-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@justeattakeaway/pie-monorepo-utils": minor
---

[Added] - Renamed `pie-git-hooks-scripts` to `pie-monorepo-utils`

**Old Changelog entries from `pie-git-hooks-scripts`**

[Changed] - Exported files for use in consuming repos ([#1206](https://github.com/justeattakeaway/pie/pull/1206)) by [@siggerzz](https://github.com/siggerzz)
[Added] - scripts for verifying branch name and commit message format ([#625](https://github.com/justeattakeaway/pie/pull/625)) by [@fernandofranca](https://github.com/fernandofranca)
5 changes: 4 additions & 1 deletion .github/project-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ pie-components-config:
tools:
- 'packages/tools/**/*'

pie-monorepo-utils:
- 'packages/tools/pie-monorepo-utils/**/*'

pie-icons:
- 'packages/tools/pie-icons/**/*'

Expand Down Expand Up @@ -125,4 +128,4 @@ pie-webc-core:
- 'packages/components/pie-webc-core/**/*'

pie-webc-testing:
- 'packages/components/pie-webc-testing/**/*'
- 'packages/components/pie-webc-testing/**/*'
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ dist/
custom-elements.json
**/src/react.ts
**/stats.html
**/component-statuses.json

# Yalc
.yalc
Expand Down
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
npx --no -- commitlint --edit ${1}

# Adds Jira ticket id to commit message
packages/tools/pie-git-hooks-scripts/check-ticket-id.js $1 $(git symbolic-ref --short HEAD)
packages/tools/pie-monorepo-utils/git-hooks/check-ticket-id.js $1 $(git symbolic-ref --short HEAD)

# Section for git-secrets
if ! command -v git-secrets &> /dev/null
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
. "$(dirname -- "$0")/_/husky.sh"

# Checks branch name for Jira ticket id
packages/tools/pie-git-hooks-scripts/check-branch-name.js $(git symbolic-ref --short HEAD)
packages/tools/pie-monorepo-utils/git-hooks/check-branch-name.js $(git symbolic-ref --short HEAD)

# Section for git-secrets
if ! command -v git-secrets &> /dev/null
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
. "$(dirname -- "$0")/_/husky.sh"

# Checks branch name for Jira ticket id
packages/tools/pie-git-hooks-scripts/check-branch-name.js $(git symbolic-ref --short HEAD)
packages/tools/pie-monorepo-utils/git-hooks/check-branch-name.js $(git symbolic-ref --short HEAD)

# Checks the diff files for lint errors before allowing to push
yarn lint:scripts lint:style
2 changes: 1 addition & 1 deletion apps/pie-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"build:dev": "DEPLOYMENT_ENVIRONMENT='development' eleventy",
"clean": "run -T rimraf dist",
"dev": "npx @11ty/eleventy --serve --port=8080",
"copy:component-statuses": "cp -v ../../component-statuses.json .",
"lint:scripts": "run -T eslint .",
"lint:scripts:fix": "run -T eslint . --fix",
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
Expand All @@ -32,6 +31,7 @@
"devDependencies": {
"@11ty/eleventy": "2.0.1",
"@11ty/eleventy-navigation": "0.3.5",
"@justeattakeaway/pie-monorepo-utils": "0.0.0",
"eleventy-plugin-rev": "1.1.1",
"eleventy-sass": "2.2.3",
"markdown-it-attrs": "4.1.6"
Expand Down
2 changes: 1 addition & 1 deletion apps/pie-docs/src/componentStatusData.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const webComponentStatuses = require('../component-statuses.json');
const webComponentStatuses = require('@justeattakeaway/pie-monorepo-utils/dist/component-statuses.json');
const resourceTypes = require('./_data/resourceTypes');
const statusTypes = require('./_data/statusTypes');

Expand Down
10 changes: 2 additions & 8 deletions apps/pie-docs/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependsOn": [
"^build",
"clean",
"copy:component-statuses"
"^generate:component-statuses"
],
"outputs": [
"dist/**"
Expand All @@ -23,7 +23,7 @@
"cache": true,
"dependsOn": [
"^build",
"copy:component-statuses"
"^generate:component-statuses"
]
},
"dev": {
Expand All @@ -32,12 +32,6 @@
"build:dev"
]
},
"copy:component-statuses": {
"dependsOn": [
"//#generate:component-statuses"
],
"cache": false
},
"test:generate-routes": {
"cache": true,
"dependsOn": [
Expand Down
2 changes: 1 addition & 1 deletion apps/pie-storybook/decorators/component-status.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type TemplateResult, html } from 'lit';
import '@justeattakeaway/pie-tag';
import '@justeattakeaway/pie-icons-webc/dist/IconHelpCircle.js';
import componentStatusesJson from '../component-statuses.json';
import componentStatusesJson from '@justeattakeaway/pie-monorepo-utils/dist/component-statuses.json';
import { type StorybookContext } from '../interfaces/storybook-context';
import { type ComponentStatuses } from '../interfaces/component-status';
import { tagVariantToStatusMap } from '../data/tag-variants-to-statuses-map';
Expand Down
2 changes: 1 addition & 1 deletion apps/pie-storybook/docblocks/component-status.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import '@justeattakeaway/pie-tag';
import componentStatusesJson from '../component-statuses.json';
import componentStatusesJson from '@justeattakeaway/pie-monorepo-utils/dist/component-statuses.json';
import { tagVariantToStatusMap } from '../data/tag-variants-to-statuses-map';
import '@justeattakeaway/pie-icons-webc/dist/IconHelpCircle.js';

Expand Down
4 changes: 2 additions & 2 deletions apps/pie-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"dev": "storybook dev -p 6006",
"build": "storybook build --output-dir dist && cp -R ./static ./dist",
"lint:scripts": "run -T eslint .",
"lint:scripts:fix": "run -T eslint . --fix",
"copy:component-statuses": "cp -v ../../component-statuses.json ."
"lint:scripts:fix": "run -T eslint . --fix"
},
"author": "Just Eat Takeaway.com - Design System Team",
"license": "Apache-2.0",
Expand Down Expand Up @@ -42,6 +41,7 @@
},
"devDependencies": {
"@justeattakeaway/pie-icons-configs": "4.5.1",
"@justeattakeaway/pie-monorepo-utils": "0.0.0",
"@storybook/addon-a11y": "8.3.0",
"@storybook/addon-designs": "8.0.3",
"@storybook/addon-essentials": "8.3.0",
Expand Down
10 changes: 2 additions & 8 deletions apps/pie-storybook/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,15 @@
"cache": false,
"dependsOn": [
"^build",
"copy:component-statuses"
"^generate:component-statuses"
]
},
"build": {
"cache": true,
"dependsOn": [
"^build",
"copy:component-statuses"
"^generate:component-statuses"
]
},
"copy:component-statuses": {
"dependsOn": [
"//#generate:component-statuses"
],
"cache": false
}
}
}
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
"./"
]
},
"bin": {
"generate-component-statuses": "./utilities/component-statuses/generate-component-statuses.js"
},
"scripts": {
"analyse-component-bundles": "bundlewatch --config bundlewatch.config.json",
"watch": "turbo run watch --filter=!pie-monorepo",
Expand All @@ -33,10 +30,9 @@
"changeset:publish": "changeset publish",
"changeset:version": "changeset version",
"clean": "turbo run clean --filter=!pie-monorepo",
"cz": "./packages/tools/pie-git-hooks-scripts/check-branch-name.js $(git symbolic-ref --short HEAD) && ./node_modules/cz-customizable/standalone.js",
"cz": "./packages/tools/pie-monorepo-utils/git-hooks/check-branch-name.js $(git symbolic-ref --short HEAD) && ./node_modules/cz-customizable/standalone.js",
"dev": "turbo run dev --filter=!pie-monorepo",
"copy:component-statuses": "cross-env-shell turbo run copy:component-statuses --filter=!pie-monorepo",
"generate:component-statuses": "npx generate-component-statuses",
"generate:component-statuses": "turbo run generate:component-statuses --filter=!pie-monorepo",
"generate:examples": "cross-env-shell turbo run generate:examples --filter=!pie-monorepo --token=${TURBO_TOKEN}",
"lint:config:fix": "eslint --fix turbo.json (packages|apps)/**/turbo.json",
"lint:examples": "cross-env-shell turbo run lint:examples --filter=!pie-monorepo --token=${TURBO_TOKEN}",
Expand Down Expand Up @@ -141,7 +137,6 @@
"yarn": "3.8.1"
},
"resolutions": {
"@babel/traverse": "7.22.5",
"lit": "3.2.0",
"tar": "6.2.1",
"@playwright/experimental-ct-core": "1.41.0"
Expand Down
13 changes: 0 additions & 13 deletions packages/tools/pie-git-hooks-scripts/CHANGELOG.md

This file was deleted.

7 changes: 0 additions & 7 deletions packages/tools/pie-git-hooks-scripts/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions packages/tools/pie-git-hooks-scripts/index.js

This file was deleted.

7 changes: 7 additions & 0 deletions packages/tools/pie-monorepo-utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<p align="center">
<img align="center" src="../../readme_image.png" height="200" alt="">
</p>

# pie-monorepo-utils

This package contains scripts and utilities used by the PIE monorepo.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
} from 'vitest';
import {
getTicketIdFromBranchName, validateBranchName, verifyCommitMessage,
} from '../git-hooks-utils';
} from '../../git-hooks/git-hooks-utils';

describe('getTicketIdFromBranchName', () => {
describe('when called with an incompatible argument', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ class ComponentStatusGenerator {

// Generates a json file with the statuses of each PIE component. The status is sourced from the package.json file of each component.
// The json will be outputted to the root of the package invoking this script as 'component-statuses.json'
async generateStatuses (workingDir) {
async generateStatuses () {
this.console.info('Generating component statuses...');

try {
const workingDir = process.cwd();
const monorepoRoot = this.findMonorepoRootSync(workingDir);

// Find components base dir
Expand Down Expand Up @@ -93,8 +94,14 @@ class ComponentStatusGenerator {

this.console.info('Component statuses:', filteredStatuses);

// write the statuses json file
const outputPath = this.path.resolve(workingDir, 'component-statuses.json');
// Ensure the dist directory exists
const distDir = this.path.resolve(workingDir, 'dist');
if (!this.fs.existsSync(distDir)) {
this.fs.mkdirSync(distDir, { recursive: true });
}

// Write the statuses json file
const outputPath = this.path.resolve(distDir, 'component-statuses.json');
await this.writeFile(outputPath, JSON.stringify(filteredStatuses, null, 2));

this.console.info(`Successfully wrote component statuses to ${outputPath}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ const generator = new ComponentStatusGenerator({
fs, path, promisify, console,
});

generator.generateStatuses(process.cwd());
generator.generateStatuses();
3 changes: 3 additions & 0 deletions packages/tools/pie-monorepo-utils/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './git-hooks/check-branch-name.js';
export * from './git-hooks/check-ticket-id.js';
export * from './git-hooks/git-hooks-utils.js';
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"name": "@justeattakeaway/pie-git-hooks-scripts",
"version": "0.2.0",
"description": "Scripts and utilities used by the Pie monorepo git hooks",
"name": "@justeattakeaway/pie-monorepo-utils",
"version": "0.0.0",
"description": "Scripts and utilities used by the PIE monorepo",
"main": "index.js",
"files": [
"dist"
],
"scripts": {
"generate:component-statuses": "node ./component-statuses/generate-component-statuses.js",
"lint:scripts": "run -T eslint .",
"lint:scripts:fix": "run -T eslint . --fix",
"test": "run -T vitest run",
Expand Down
14 changes: 14 additions & 0 deletions packages/tools/pie-monorepo-utils/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://turborepo.org/schema.json",
"extends": [
"//"
],
"pipeline": {
"generate:component-statuses": {
"cache": false,
"outputs": [
"./dist/component-statuses.json"
]
}
}
}
16 changes: 2 additions & 14 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,9 @@
".output/**"
]
},
"//#generate:component-statuses": {
"cache": true,
"inputs": [
"packages/components/**/package.json",
"!packages/components/pie-webc",
"!packages/components/pie-webc-core",
"!packages/components/pie-webc-testing"
],
"outputs": [
"component-statuses.json"
]
},
"copy:component-statuses": {},
"generate:component-statuses": {},
"watch": {
"cache": true,
"cache": false,
"dependsOn": []
},
"clean": {
Expand Down
Loading

0 comments on commit 8c43af8

Please sign in to comment.