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

[CLI] Add tabs command #403

Merged
merged 2 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ $ rush build

- Commit all code changes with a commit message starting with `[RELEASE] 0.1.3-4.`

### Optional use of Rush Change for formatted changelog

- Use `rush change` to update the Changelog. Commit and squash these changes into the `[RELEASE] X.Y.Z-Q` commit.

- 🎉 Congratulations! You've released a new set of `@misk` packages! Downstream `misk-web` tabs can now simply update the `version` in their `miskTab.json` and on their next build, they will start using the latest packages.
Expand Down
2 changes: 1 addition & 1 deletion common/config/rush/version-policies.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{
"definitionName": "lockStepVersion",
"policyName": "MiskWeb",
"version": "0.1.7",
"version": "0.1.8",
"nextBump": "patch"
}
// {
Expand Down
6 changes: 3 additions & 3 deletions examples/data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"prepare": "npm run-script build"
},
"dependencies": {
"@misk/core": "0.1.7",
"@misk/core": "0.1.8",
"fs-extra": "8.0.1"
},
"devDependencies": {
"@misk/dev": "0.1.7",
"@misk/dev": "0.1.8",
"@types/fs-extra": "7.0.0",
"@misk/tslint": "0.1.7",
"@misk/tslint": "0.1.8",
"@types/node": "11.13.1",
"@types/prop-types": "15.7.1",
"@types/react": "16.8.21",
Expand Down
4 changes: 2 additions & 2 deletions examples/services/dashboard/demo/@misk/common/styles.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/services/dashboard/miskTab.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"relative_path_prefix": "",
"slug": "dashboard",
"useWebpackExternals": true,
"version": "0.1.7",
"version": "0.1.8",
"zipOnBuild": false,
"___DeprecatedKeys": "Any keys below this point in your miskTab.json are deprecated and can be safely removed."
}
12 changes: 6 additions & 6 deletions examples/services/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"zip": "tar --exclude='.gitignore' --exclude='.old_build_files' --exclude='package.json' --exclude='package-lock.json' --exclude='prettier.config.js' --exclude='tsconfig.json' --exclude='tslint.json' --exclude='webpack.config.js' --exclude='yarn.lock' --exclude='demo' --exclude='lib' --exclude='.DS_Store' --exclude='*.log' --exclude='node_modules' --exclude='dashboard.tgz' -czvf dashboard.tgz ./"
},
"dependencies": {
"@misk/common": "0.1.7",
"@misk/core": "0.1.7",
"@misk/simpleredux": "0.1.7",
"@misk/common": "0.1.8",
"@misk/core": "0.1.8",
"@misk/simpleredux": "0.1.8",
"@blueprintjs/core": "3.16.0",
"@blueprintjs/datetime": "3.10.0",
"@blueprintjs/icons": "3.9.0",
Expand Down Expand Up @@ -52,9 +52,9 @@
"styled-components": "4.3.2"
},
"devDependencies": {
"@misk/dev": "0.1.7",
"@misk/test": "0.1.7",
"@misk/tslint": "0.1.7",
"@misk/dev": "0.1.8",
"@misk/test": "0.1.8",
"@misk/tslint": "0.1.8",
"@types/history": "4.7.2",
"@types/jest": "24.0.15",
"@types/node": "11.13.1",
Expand Down
2 changes: 1 addition & 1 deletion examples/tabs/palette-exemplar/miskTab.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"relative_path_prefix": "",
"slug": "palette-exemplar",
"useWebpackExternals": true,
"version": "0.1.7",
"version": "0.1.8",
"zipOnBuild": true,
"___DeprecatedKeys": "Any keys below this point in your miskTab.json are deprecated and can be safely removed."
}
12 changes: 6 additions & 6 deletions examples/tabs/palette-exemplar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"zip": "tar --exclude='.gitignore' --exclude='.old_build_files' --exclude='package.json' --exclude='package-lock.json' --exclude='prettier.config.js' --exclude='tsconfig.json' --exclude='tslint.json' --exclude='webpack.config.js' --exclude='yarn.lock' --exclude='demo' --exclude='lib' --exclude='.DS_Store' --exclude='*.log' --exclude='node_modules' --exclude='palette-exemplar.tgz' -czvf palette-exemplar.tgz ./"
},
"dependencies": {
"@misk/common": "0.1.6",
"@misk/core": "0.1.6",
"@misk/simpleredux": "0.1.6",
"@misk/common": "0.1.7",
"@misk/core": "0.1.7",
"@misk/simpleredux": "0.1.7",
"@blueprintjs/core": "3.16.0",
"@blueprintjs/datetime": "3.10.0",
"@blueprintjs/icons": "3.9.0",
Expand Down Expand Up @@ -52,10 +52,10 @@
"styled-components": "4.3.2"
},
"devDependencies": {
"@misk/dev": "0.1.6",
"@misk/test": "0.1.6",
"@misk/dev": "0.1.7",
"@misk/test": "0.1.7",
"jest-emotion": "10.0.11",
"@misk/tslint": "0.1.6",
"@misk/tslint": "0.1.7",
"@types/history": "4.7.2",
"@types/jest": "24.0.15",
"@types/node": "11.13.1",
Expand Down
Binary file modified examples/tabs/palette-exemplar/palette-exemplar.tgz
Binary file not shown.
4 changes: 2 additions & 2 deletions examples/tabs/palette/demo/@misk/common/styles.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/tabs/palette/miskTab.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"relative_path_prefix": "_admin/",
"slug": "palette",
"useWebpackExternals": true,
"version": "0.1.7",
"version": "0.1.8",
"zipOnBuild": true,
"___DeprecatedKeys": "Any keys below this point in your miskTab.json are deprecated and can be safely removed."
}
12 changes: 6 additions & 6 deletions examples/tabs/palette/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"zip": "tar --exclude='.gitignore' --exclude='.old_build_files' --exclude='package.json' --exclude='package-lock.json' --exclude='prettier.config.js' --exclude='tsconfig.json' --exclude='tslint.json' --exclude='webpack.config.js' --exclude='yarn.lock' --exclude='demo' --exclude='lib' --exclude='.DS_Store' --exclude='*.log' --exclude='node_modules' --exclude='palette.tgz' -czvf palette.tgz ./"
},
"dependencies": {
"@misk/common": "0.1.7",
"@misk/core": "0.1.7",
"@misk/simpleredux": "0.1.7",
"@misk/common": "0.1.8",
"@misk/core": "0.1.8",
"@misk/simpleredux": "0.1.8",
"@blueprintjs/core": "3.16.0",
"@blueprintjs/datetime": "3.10.0",
"@blueprintjs/icons": "3.9.0",
Expand Down Expand Up @@ -52,9 +52,9 @@
"styled-components": "4.3.2"
},
"devDependencies": {
"@misk/dev": "0.1.7",
"@misk/test": "0.1.7",
"@misk/tslint": "0.1.7",
"@misk/dev": "0.1.8",
"@misk/test": "0.1.8",
"@misk/tslint": "0.1.8",
"@types/history": "4.7.2",
"@types/jest": "24.0.15",
"@types/node": "11.13.1",
Expand Down
Binary file modified examples/tabs/palette/palette.tgz
Binary file not shown.
6 changes: 6 additions & 0 deletions packages/@misk/cli/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"name": "@misk/cli",
"entries": [
{
"version": "0.1.8",
"tag": "@misk/cli_v0.1.8",
"date": "Thu, 11 Jul 2019 17:39:26 GMT",
"comments": {}
},
{
"version": "0.1.7",
"tag": "@misk/cli_v0.1.7",
Expand Down
7 changes: 6 additions & 1 deletion packages/@misk/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Change Log - @misk/cli

This log was last generated on Fri, 28 Jun 2019 14:39:38 GMT and should not be manually modified.
This log was last generated on Thu, 11 Jul 2019 17:39:26 GMT and should not be manually modified.

## 0.1.8
Thu, 11 Jul 2019 17:39:26 GMT

*Version update only*

## 0.1.7
Fri, 28 Jun 2019 14:39:38 GMT
Expand Down
7 changes: 4 additions & 3 deletions packages/@misk/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ Commands:

miskweb start start Webpack Dev Server for live editing

miskweb test-coverage generate test coverage report with `jest --
--coverage`
miskweb tabs prints path of all downstream tabs

miskweb test-update update test snapshots with `jest -- -u`
miskweb test-coverage generate test coverage report

miskweb test-update update test snapshots

miskweb test run tests

Expand Down
8 changes: 4 additions & 4 deletions packages/@misk/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@misk/cli",
"version": "0.1.7",
"version": "0.1.8",
"license": "SEE LICENSE IN https://github.com/cashapp/misk-web",
"description": "Misk-Web CLI Build Tool",
"author": "CashApp/Misk-Web Authors (https://github.com/cashapp/misk-web/graphs/contributors)",
Expand Down Expand Up @@ -31,7 +31,7 @@
"test": "jest --passWithNoTests"
},
"dependencies": {
"@misk/test": "0.1.7",
"@misk/test": "0.1.8",
"axios": "0.19.0",
"dayjs": "1.8.14",
"fs-extra": "8.0.1",
Expand All @@ -47,14 +47,14 @@
"yargs": "13.2.4"
},
"devDependencies": {
"@misk/dev": "0.1.7",
"@misk/dev": "0.1.8",
"@types/jest": "24.0.15",
"jest": "24.8.0",
"jest-emotion": "10.0.11",
"jest-serializer-html": "7.0.0",
"react-testing-library": "6.1.2",
"ts-jest": "24.0.2",
"@misk/tslint": "0.1.7",
"@misk/tslint": "0.1.8",
"@types/fs-extra": "7.0.0",
"@types/klaw": "3.0.0",
"@types/lodash": "4.14.134",
Expand Down
7 changes: 7 additions & 0 deletions packages/@misk/cli/src/commands/tabs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { execute, handleCommand } from "../utils"
export const command = "tabs"
export const desc = "prints path of all downstream tabs\n"
export const handlerFn = async (...args: any) => {
execute("pwd", ...args)
}
export const handler = async (yargs: any) => handleCommand({ ...yargs, each: true, hideProgress: true }, handlerFn)
34 changes: 24 additions & 10 deletions packages/@misk/cli/src/utils/handleCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const autoUpdate = async () => {
formattedLog(
"Auto-Update",
`updating miskweb CLI from ${packageVersion} to ${latestOnlineVersion ||
"latest"}`,
"latest"}`,
"NPM"
)
execute("npm install -g @misk/cli")
Expand All @@ -47,10 +47,12 @@ export const handleCommand = async (
e: boolean
each: boolean
$0: string
hideProgress: boolean
},
handlerFn: (...args: any) => void,
blockedOptions: string[] = []
) => {
// Node version check
const { node: nodeVersion } = process.versions
if (parseInt(nodeVersion.split(".")[0]) !== 10) {
formattedLog(
Expand All @@ -60,21 +62,27 @@ export const handleCommand = async (
)
}
const latestOnlineVersion = await packageVersionExistsOnNPM()

// CLI version check
if (
packageVersion !== latestOnlineVersion &&
latestOnlineVersion !== PackageVersionStatus.OFFLINE
) {
console.log(
`[ALERT] Upgrade miskweb CLI from ${packageVersion} to ${latestOnlineVersion ||
"latest"} with '$ miskweb update'`
"latest"} with '$ miskweb update'`
)
}

// Blocked options (ie. not allowing -e on miskweb start)
let invalidOptions: string[] = []
blockedOptions.map((opt: string) => {
if (opt in args) {
invalidOptions.push(opt)
}
})

// Execute command
if (invalidOptions.length > 0) {
console.error(
`Invalid use of ${invalidOptions.map(
Expand All @@ -87,29 +95,35 @@ export const handleCommand = async (
.hide("version")
.showHelp()
} else if (args.each) {
const bar = new ProgressBar(`[EACH][:bar]`, {
complete: "=",
incomplete: " ",
width: 80,
total: 10
})
// Find all downstream tabs and execute command in that tab directory
let bar: any = null
if (!args.hideProgress) {
bar = new ProgressBar(`[EACH][:bar]`, {
complete: "=",
incomplete: " ",
width: 80,
total: 10
})
}

const tabs: string[] = []
klaw(".", { filter: filterFunc })
.on("data", (item: any) => {
if (item.stats.isFile() && item.path.includes("/miskTab.json")) {
if (tabs.length < 10) bar.tick(1)
if (!args.hideProgress && tabs.length < 10) bar.tick(1)
tabs.push(item.path.split("/miskTab.json")[0])
}
})
.on("error", (err: Error) => console.error(err))
.on("end", async () => {
bar.tick(10 - tabs.length)
if (!args.hideProgress) bar.tick(10 - tabs.length)
for (const tab in tabs) {
cd(tabs[tab])
handlerFn({ ...args, dir: tabs[tab] })
}
})
} else {
// Execute command in current directory
handlerFn(args)
}
}
6 changes: 6 additions & 0 deletions packages/@misk/common/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"name": "@misk/common",
"entries": [
{
"version": "0.1.8",
"tag": "@misk/common_v0.1.8",
"date": "Thu, 11 Jul 2019 17:39:26 GMT",
"comments": {}
},
{
"version": "0.1.7",
"tag": "@misk/common_v0.1.7",
Expand Down
7 changes: 6 additions & 1 deletion packages/@misk/common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Change Log - @misk/common

This log was last generated on Fri, 28 Jun 2019 14:39:38 GMT and should not be manually modified.
This log was last generated on Thu, 11 Jul 2019 17:39:26 GMT and should not be manually modified.

## 0.1.8
Thu, 11 Jul 2019 17:39:26 GMT

*Version update only*

## 0.1.7
Fri, 28 Jun 2019 14:39:38 GMT
Expand Down
6 changes: 3 additions & 3 deletions packages/@misk/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@misk/common",
"version": "0.1.7",
"version": "0.1.8",
"license": "SEE LICENSE IN https://github.com/cashapp/misk-web",
"description": "Misk-Web Common Libraries, Styles",
"author": "CashApp/Misk-Web Authors (https://github.com/cashapp/misk-web/graphs/contributors)",
Expand Down Expand Up @@ -66,8 +66,8 @@
"styled-components": "4.3.2"
},
"devDependencies": {
"@misk/dev": "0.1.7",
"@misk/tslint": "0.1.7",
"@misk/dev": "0.1.8",
"@misk/tslint": "0.1.8",
"@types/history": "4.7.2",
"@types/lodash": "4.14.134",
"@types/node": "11.13.1",
Expand Down
6 changes: 6 additions & 0 deletions packages/@misk/core/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"name": "@misk/core",
"entries": [
{
"version": "0.1.8",
"tag": "@misk/core_v0.1.8",
"date": "Thu, 11 Jul 2019 17:39:26 GMT",
"comments": {}
},
{
"version": "0.1.7",
"tag": "@misk/core_v0.1.7",
Expand Down
7 changes: 6 additions & 1 deletion packages/@misk/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Change Log - @misk/core

This log was last generated on Fri, 28 Jun 2019 14:39:38 GMT and should not be manually modified.
This log was last generated on Thu, 11 Jul 2019 17:39:26 GMT and should not be manually modified.

## 0.1.8
Thu, 11 Jul 2019 17:39:26 GMT

*Version update only*

## 0.1.7
Fri, 28 Jun 2019 14:39:38 GMT
Expand Down
Loading