Skip to content

Commit cc46a18

Browse files
authored
feat: cloudy version 0.0.3 (#17)
1 parent 019ff60 commit cc46a18

File tree

18 files changed

+5212
-5549
lines changed

18 files changed

+5212
-5549
lines changed

README.md

Lines changed: 124 additions & 213 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
2-
"name": "cloudy",
3-
"version": "0.0.0",
4-
"description": "Deploy full served clusters in seconds using CLI",
2+
"name": "@cloudytool/cloudy",
3+
"private": false,
4+
"version": "0.0.3",
5+
"description": "Cloudy is an \"infrastructure as code\" tool for managing production-grade cloud clusters.",
56
"author": "Ivan Fokeev @ifokeev",
67
"bin": {
78
"cloudy": "./bin/run"
89
},
9-
"homepage": "https://github.com/cloudy/cloudy",
10+
"homepage": "https://github.com/cloudytool/cloudy",
1011
"license": "MIT",
1112
"main": "dist/index.js",
12-
"repository": "cloudy/cloudy",
13+
"repository": "cloudytool/cloudy",
1314
"files": [
1415
"/bin",
1516
"/dist",
@@ -21,12 +22,12 @@
2122
"@oclif/errors": "^1.3.5",
2223
"@oclif/plugin-help": "^5",
2324
"@oclif/plugin-not-found": "^2.3.1",
24-
"@oclif/plugin-plugins": "^2.0.1",
2525
"@oclif/plugin-update": "^3.0.0",
2626
"@oclif/plugin-warn-if-update-available": "^2.0.4",
2727
"cli-ux": "^6.0.9",
2828
"fs-extra": "^10.1.0",
2929
"git-clone": "^0.2.0",
30+
"which": "^2.0.2",
3031
"write-yaml-file": "^4.2.0"
3132
},
3233
"devDependencies": {
@@ -36,6 +37,7 @@
3637
"@types/git-clone": "^0.2.0",
3738
"@types/mocha": "^9.0.0",
3839
"@types/node": "^16.9.4",
40+
"@types/which": "^2.0.1",
3941
"chai": "^4",
4042
"eslint": "^7.32.0",
4143
"eslint-config-oclif": "^4",
@@ -53,15 +55,17 @@
5355
"dirname": "cloudy",
5456
"commands": "./dist/commands",
5557
"plugins": [
56-
"@oclif/plugin-help",
57-
"@oclif/plugin-plugins"
58+
"@oclif/plugin-help"
5859
],
59-
"topicSeparator": " ",
60-
"topics": {
61-
"hello": {
62-
"description": "Say hello to the world and others"
60+
"macos": {
61+
"identifier": "com.cloudy.cli"
62+
},
63+
"update": {
64+
"s3": {
65+
"bucket": "cloudy-releases"
6366
}
64-
}
67+
},
68+
"topicSeparator": " "
6569
},
6670
"scripts": {
6771
"build": "shx rm -rf dist && tsc -b",
@@ -71,14 +75,22 @@
7175
"posttest": "yarn lint",
7276
"prepack": "yarn build && oclif manifest && oclif readme",
7377
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
74-
"version": "oclif readme && git add README.md"
78+
"version": "oclif readme && git add README.md",
79+
"push": "yarn publish --access public"
7580
},
7681
"engines": {
7782
"node": ">=12.0.0"
7883
},
79-
"bugs": "https://github.com/cloudy/cloudy/issues",
84+
"bugs": "https://github.com/cloudytool/cloudy/issues",
8085
"keywords": [
81-
"oclif"
86+
"oclif",
87+
"pulumi",
88+
"cloud",
89+
"infrastructure",
90+
"as code",
91+
"cli",
92+
"cloudy",
93+
"cloudy lab"
8294
],
8395
"types": "dist/index.d.ts"
8496
}

src/commands/destroy.ts

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,46 @@
1+
import * as path from 'node:path'
2+
import {execSync} from 'node:child_process'
13
import {Command, Flags} from '@oclif/core'
4+
import Doctor from './doctor'
5+
6+
import {PULUMI_CONFIG_PASSPHRASE, PULUMI_CONFIG_PASSPHRASE_FILE} from '../constants'
27

38
export default class Destroy extends Command {
4-
static description = 'describe the command here'
9+
static description = 'Destroy Pulumi project deployment'
510

611
static examples = [
7-
'<%= config.bin %> <%= command.id %>',
12+
'<%= config.bin %> <%= command.id %> aws-cluster',
813
]
914

1015
static flags = {
11-
// flag with a value (-n, --name=VALUE)
12-
name: Flags.string({char: 'n', description: 'name to print'}),
13-
// flag with no value (-f, --force)
14-
force: Flags.boolean({char: 'f'}),
16+
root: Flags.string({char: 'r', description: 'Root path to the project'}),
1517
}
1618

17-
static args = [{name: 'file'}]
19+
static args = [{
20+
name: 'projectName',
21+
required: true,
22+
}]
1823

1924
public async run(): Promise<void> {
2025
const {args, flags} = await this.parse(Destroy)
2126

22-
const name = flags.name ?? 'world'
23-
this.log(`hello ${name} from /Users/user/Code/cloudy/src/commands/destroy.ts`)
24-
if (args.file && flags.force) {
25-
this.log(`you input --force and --file: ${args.file}`)
26-
}
27+
const cwd = process.cwd()
28+
const {projectName} = args
29+
const projectRoot = flags.root ?? cwd
30+
const projectPath = path.join(projectRoot, 'projects', projectName)
31+
32+
await Doctor.run()
33+
34+
const cmdName = this.constructor.name.toLowerCase()
35+
36+
const cmd = [
37+
`export PULUMI_CONFIG_PASSPHRASE="${PULUMI_CONFIG_PASSPHRASE}"`,
38+
`export PULUMI_CONFIG_PASSPHRASE_FILE="${PULUMI_CONFIG_PASSPHRASE_FILE}"`,
39+
`cd ${projectPath}`,
40+
'yarn',
41+
`${process.env.SHELL} ${cmdName}.sh ${projectName}`,
42+
].join(' && ')
43+
44+
execSync(`(${cmd})`, {stdio: 'inherit'})
2745
}
2846
}

src/commands/doctor.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import {Command} from '@oclif/core'
2+
import * as which from 'which'
3+
4+
export default class Doctor extends Command {
5+
static description = 'Check CLI issues'
6+
7+
static examples = [
8+
'<%= config.bin %> <%= command.id %>',
9+
]
10+
11+
public async run(): Promise<void> {
12+
const hasGit = which.sync('git', {nothrow: true})
13+
const hasYarn = which.sync('yarn', {nothrow: true})
14+
const hasPulumi = which.sync('pulumi', {nothrow: true})
15+
16+
if (!hasGit) {
17+
this.error('Please install git (https://git-scm.com/downloads)')
18+
}
19+
20+
if (!hasYarn) {
21+
this.error('Please install yarn (https://classic.yarnpkg.com/lang/en/docs/install)')
22+
}
23+
24+
if (!hasPulumi) {
25+
this.error('Please install pulumi (https://www.pulumi.com/docs/get-started/install)')
26+
}
27+
28+
this.log('** Everything looks good! **')
29+
}
30+
}

src/commands/export.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import * as path from 'node:path'
2+
import {execSync} from 'node:child_process'
3+
import {Command, Flags} from '@oclif/core'
4+
import Doctor from './doctor'
5+
6+
import {PULUMI_CONFIG_PASSPHRASE, PULUMI_CONFIG_PASSPHRASE_FILE} from '../constants'
7+
8+
export default class Export extends Command {
9+
static description = 'Export Pulumi project state'
10+
11+
static examples = [
12+
'<%= config.bin %> <%= command.id %> aws-cluster',
13+
]
14+
15+
static flags = {
16+
root: Flags.string({char: 'r', description: 'Root path to the project'}),
17+
}
18+
19+
static args = [{
20+
name: 'projectName',
21+
required: true,
22+
}]
23+
24+
public async run(): Promise<void> {
25+
const {args, flags} = await this.parse(Export)
26+
27+
const cwd = process.cwd()
28+
const {projectName} = args
29+
const projectRoot = flags.root ?? cwd
30+
const projectPath = path.join(projectRoot, 'projects', projectName)
31+
32+
await Doctor.run()
33+
34+
const cmdName = this.constructor.name.toLowerCase()
35+
36+
const cmd = [
37+
`export PULUMI_CONFIG_PASSPHRASE="${PULUMI_CONFIG_PASSPHRASE}"`,
38+
`export PULUMI_CONFIG_PASSPHRASE_FILE="${PULUMI_CONFIG_PASSPHRASE_FILE}"`,
39+
`cd ${projectPath}`,
40+
'yarn',
41+
`${process.env.SHELL} ${cmdName}.sh ${projectName}`,
42+
].join(' && ')
43+
44+
execSync(`(${cmd})`, {stdio: 'inherit'})
45+
}
46+
}

src/commands/import.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import * as path from 'node:path'
2+
import {execSync} from 'node:child_process'
3+
import {Command, Flags} from '@oclif/core'
4+
import Doctor from './doctor'
5+
6+
import {PULUMI_CONFIG_PASSPHRASE, PULUMI_CONFIG_PASSPHRASE_FILE} from '../constants'
7+
8+
export default class Import extends Command {
9+
static description = 'Import Pulumi project state'
10+
11+
static examples = [
12+
'<%= config.bin %> <%= command.id %> aws-cluster',
13+
]
14+
15+
static flags = {
16+
root: Flags.string({char: 'r', description: 'Root path to the project'}),
17+
}
18+
19+
static args = [{
20+
name: 'projectName',
21+
required: true,
22+
}]
23+
24+
public async run(): Promise<void> {
25+
const {args, flags} = await this.parse(Import)
26+
27+
const cwd = process.cwd()
28+
const {projectName} = args
29+
const projectRoot = flags.root ?? cwd
30+
const projectPath = path.join(projectRoot, 'projects', projectName)
31+
32+
await Doctor.run()
33+
34+
const cmdName = this.constructor.name.toLowerCase()
35+
36+
const cmd = [
37+
`export PULUMI_CONFIG_PASSPHRASE="${PULUMI_CONFIG_PASSPHRASE}"`,
38+
`export PULUMI_CONFIG_PASSPHRASE_FILE="${PULUMI_CONFIG_PASSPHRASE_FILE}"`,
39+
`cd ${projectPath}`,
40+
'yarn',
41+
`${process.env.SHELL} ${cmdName}.sh ${projectName}`,
42+
].join(' && ')
43+
44+
execSync(`(${cmd})`, {stdio: 'inherit'})
45+
}
46+
}

0 commit comments

Comments
 (0)