Skip to content

Commit

Permalink
Replace usage of uuid with incrementing id (#179)
Browse files Browse the repository at this point in the history
Fixes #111
  • Loading branch information
ryanbraganza authored and emmatown committed Oct 4, 2019
1 parent 1b73014 commit df35f32
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-balloons-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/cli": patch
---

Remove dependency on uuid
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"@types/meow": "^5.0.0",
"@types/prettier": "^1.18.0",
"@types/semver": "^6.0.0",
"@types/uuid": "^3.4.4",
"@typescript-eslint/eslint-plugin": "^1.9.0",
"@typescript-eslint/parser": "^1.9.0",
"boxen": "^1.3.0",
Expand Down Expand Up @@ -89,8 +88,7 @@
"strip-ansi": "^5.2.0",
"term-size": "^2.1.0",
"tty-table": "^2.7.0",
"typescript": "^3.4.5",
"uuid": "^3.3.2"
"typescript": "^3.4.5"
},
"preconstruct": {
"packages": [
Expand Down
4 changes: 1 addition & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"@changesets/read": "^0.2.2",
"@changesets/types": "^0.3.0",
"@types/semver": "^6.0.0",
"@types/uuid": "^3.4.4",
"boxen": "^1.3.0",
"chalk": "^2.1.0",
"cli-table": "^0.3.1",
Expand All @@ -54,8 +53,7 @@
"semver": "^5.4.1",
"spawndamnit": "^2.0.0",
"term-size": "^2.1.0",
"tty-table": "^2.7.0",
"uuid": "^3.3.2"
"tty-table": "^2.7.0"
},
"devDependencies": {
"@changesets/parse": "^0.2.1",
Expand Down
15 changes: 9 additions & 6 deletions packages/cli/src/utils/cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import uuid from "uuid/v1";
// @ts-ignore it's not worth writing a TS declaration file in this repo for a tiny module we use once like this
import termSize from "term-size";
import logger, { prefix } from "./logger";
Expand All @@ -8,8 +7,12 @@ import { prompt } from "enquirer";
/* Notes on using inquirer:
* Each question needs a key, as inquirer is assembling an object behind-the-scenes.
* At each call, the entire responses object is returned, so we need a unique
* identifier for the name every time. This is why we are using UUIDs.
* identifier for the name every time. This is why we are using serial IDs
*/
const serialId: () => number = (function() {
let id = 0;
return () => id++;
})();

const limit = Math.max(termSize().rows - 5, 10);

Expand All @@ -23,7 +26,7 @@ async function askCheckboxPlus(
choices: Array<any>,
format?: (arg: any) => any
): Promise<Array<string>> {
const name = `CheckboxPlus-${uuid()}`;
const name = `CheckboxPlus-${serialId()}`;

return prompt({
type: "autocomplete",
Expand All @@ -44,7 +47,7 @@ async function askCheckboxPlus(
}

async function askQuestion(message: string): Promise<string> {
const name = `Question-${uuid()}`;
const name = `Question-${serialId()}`;

return prompt([
{
Expand All @@ -63,7 +66,7 @@ async function askQuestion(message: string): Promise<string> {
}

async function askConfirm(message: string): Promise<boolean> {
const name = `Confirm-${uuid()}`;
const name = `Confirm-${serialId()}`;

return prompt([
{
Expand All @@ -86,7 +89,7 @@ async function askList(
message: string,
choices: Array<string>
): Promise<string> {
const name = `List-${uuid()}`;
const name = `List-${serialId()}`;

return prompt([
{
Expand Down
7 changes: 0 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1029,13 +1029,6 @@
version "1.0.1"
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e"

"@types/uuid@^3.4.4":
version "3.4.4"
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-3.4.4.tgz#7af69360fa65ef0decb41fd150bf4ca5c0cefdf5"
integrity sha512-tPIgT0GUmdJQNSHxp0X2jnpQfBSTfGxUMc/2CXBU2mnyTFVYVa2ojpoQ74w0U2yn2vw3jnC640+77lkFFpdVDw==
dependencies:
"@types/node" "*"

"@types/yargs@^12.0.2", "@types/yargs@^12.0.9":
version "12.0.12"
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-12.0.12.tgz#45dd1d0638e8c8f153e87d296907659296873916"
Expand Down

0 comments on commit df35f32

Please sign in to comment.