From bb4c2b1f82bac2881a86becc2bb6f2fa4ac6d23d Mon Sep 17 00:00:00 2001 From: Dan Goodman Date: Thu, 14 Oct 2021 11:23:23 -0400 Subject: [PATCH] Working name generation --- lib/commands/instance/init.ts | 11 +++++++++-- npm-shrinkwrap.json | 10 +++++----- package.json | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/commands/instance/init.ts b/lib/commands/instance/init.ts index c5539387..72c2e8ce 100644 --- a/lib/commands/instance/init.ts +++ b/lib/commands/instance/init.ts @@ -26,7 +26,14 @@ import * as fs from 'fs' import * as fetch from 'isomorphic-fetch' import * as cf from '../../utils/common-flags'; import { flags } from '@oclif/command'; -import { nanoid } from 'nanoid/non-secure'; +import { uniqueNamesGenerator, adjectives, colors, animals } from 'unique-names-generator' + +function randomName() { + return uniqueNamesGenerator({ + dictionaries: [adjectives, colors, animals], + separator: '-' + }) +} interface FlagsDef { help: void; @@ -179,7 +186,7 @@ export default class InstanceInitCmd extends Command { responseBody = await res.json() const sshKeyID = responseBody.ssh_keys[0].id - const randomDropletID = nanoid() + const randomDropletID = randomName() console.log('Creating droplet...') res = await fetch('https://api.digitalocean.com/v2/droplets', { diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 58564780..76679260 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -12439,11 +12439,6 @@ "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==" }, - "nanoid": { - "version": "3.1.30", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.30.tgz", - "integrity": "sha512-zJpuPDwOv8D2zq2WRoMe1HsfZthVewpel9CAvTfc/2mBD1uUT/agc5f7GHGWXlYkFvi1mVxe4IjvP2HNrop7nQ==" - }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", @@ -18097,6 +18092,11 @@ "set-value": "^2.0.1" } }, + "unique-names-generator": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/unique-names-generator/-/unique-names-generator-4.6.0.tgz", + "integrity": "sha512-m0fke1emBeT96UYn2psPQYwljooDWRTKt9oUZ5vlt88ZFMBGxqwPyLHXwCfkbgdm8jzioCp7oIpo6KdM+fnUlQ==" + }, "unique-stream": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-2.3.1.tgz", diff --git a/package.json b/package.json index 36c76882..024d5b47 100644 --- a/package.json +++ b/package.json @@ -253,7 +253,6 @@ "minimatch": "^3.0.4", "moment": "^2.27.0", "moment-duration-format": "^2.3.2", - "nanoid": "^3.1.30", "ndjson": "^2.0.0", "net-keepalive": "^3.0.0", "node-cleanup": "^2.1.2", @@ -284,6 +283,7 @@ "through2": "^2.0.3", "tmp": "^0.2.1", "typed-error": "^3.2.1", + "unique-names-generator": "^4.6.0", "update-notifier": "^4.1.0", "which": "^2.0.2", "window-size": "^1.1.0"