Working name generation

This commit is contained in:
Dan Goodman 2021-10-14 11:23:23 -04:00 committed by ab77
parent 2a8bd18e9b
commit bb4c2b1f82
No known key found for this signature in database
GPG Key ID: D094F44E5E29445A
3 changed files with 15 additions and 8 deletions

View File

@ -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', {

10
npm-shrinkwrap.json generated
View File

@ -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",

View File

@ -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"