Skip to content

Commit

Permalink
cli
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra committed Sep 26, 2019
1 parent e146651 commit 7268d8a
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 128 deletions.
49 changes: 0 additions & 49 deletions old-packages/insights-server/package.json

This file was deleted.

69 changes: 0 additions & 69 deletions old-packages/insights-server/yarn.lock

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// - INSIGHTS_SUPERUSER_EMAIL
// - INSIGHTS_SUPERUSER_PASSWORD

const app = require('insights-core/src')
const app = require('insights-api/src')
const prompt = require('prompt-promise')
const randomString = require('insights-core/src/lib/random-string')
const randomString = require('../lib/random-string')

const azAZ09 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'

Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions packages/insights-cli/bin/insights
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ var pkg = require(path.join(root, 'package.json'))

program.version(pkg.version)
.usage('<command> [options]')
.description('Run insights dekstop app, server or helper commands')
.description('Run insights server or helper commands')

program
.command('desktop', 'run the desktop/electron app [default]', { isDefault: true })
.command('server', 'run as a server')
.command('start', 'run as a server')
.command('createsecret', 'create a new authentication secret')
.command('createsuperuser', 'create a new admin user')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var path = require('path')
var program = require('commander')
var root = path.join(__dirname, '..')
var pkg = require(path.join(root, 'package.json'))
var randomString = require('insights-core/src/lib/random-string')
var randomString = require('../lib/random-string')

program.version(pkg.version)
.usage('[options]')
Expand All @@ -15,6 +15,16 @@ program.version(pkg.version)

const secretPath = program.secret || path.join(require('os').homedir(), '.insights', 'secret')

let folder = secretPath.split(path.sep)
folder.pop()
const folderPath = folder.join(path.sep)
try {
fs.mkdirSync(folderPath, { recursive: true })
} catch (error) {
console.error(`Fatal Error! Could not create folder ${folderPath}`)
process.exit(1)
}

try {
fs.writeFileSync(secretPath, randomString(64), 'utf8')
console.log(`New authentication secret stored at ${secretPath}`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var path = require('path')
var program = require('commander')
var root = path.join(__dirname, '..')
var pkg = require(path.join(root, 'package.json'))
var randomString = require('insights-core/src/lib/random-string')
var randomString = require('../lib/random-string')

program.version(pkg.version)
.usage('[options]')
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions packages/insights-cli/lib/random-string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
let az09 = 'abcdefghijklmnopqrstuvwxyz0123456789'

module.exports = function randomString (len, charset = az09) {
let text = ''
for (let i = 0; i < len; i++) {
text += charset.charAt(Math.floor(Math.random() * charset.length))
}
return text
}
9 changes: 6 additions & 3 deletions packages/insights-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
"contributors": [],
"repository": "mariusandra/insights",
"bugs": {},
"bin": {
"insights": "./bin/insights",
"insights-start": "./bin/insights-start",
"insights-createsecret": "./bin/insights-createsecret",
"insights-createsuperuser": "./bin/insights-createsuperuser"
},
"directories": {
"lib": "app"
},
Expand All @@ -24,9 +30,6 @@
"yarn": ">= 0.18.0"
},
"scripts": {},
"bin": {
"insights": "./bin/insights"
},
"files": [
"bin"
],
Expand Down

0 comments on commit 7268d8a

Please sign in to comment.