Skip to content

Commit

Permalink
0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
inxilpro committed Nov 14, 2018
1 parent d78593c commit 0ab05f2
Show file tree
Hide file tree
Showing 13 changed files with 49,219 additions and 37 deletions.
24,535 changes: 24,535 additions & 0 deletions dist/ansible-interactive.js

Large diffs are not rendered by default.

Binary file added dist/bin/ansible-interactive
Binary file not shown.
24,536 changes: 24,536 additions & 0 deletions dist/js/ansible-interactive

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
},
"devDependencies": {
"nexe": "^2.0.0-rc.34",
"rollup": "^0.67.1"
"rollup": "^0.67.1",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-node-resolve": "^3.4.0"
},
"scripts": {
"build": "rollup -c rollup.config.js",
"clean-dist": "rm -rf dist/",
"make-dist-dirs": "mkdir -p dist/js && mkdir -p dist/bin",
"dist-js": "echo '#!/usr/bin/env node' | cat - dist/ansible-interactive.js > dist/js/ansible-interactive && chmod +x dist/js/ansible-interactive",
"dist-bin": "nexe -i dist/ansible-interactive.js -o dist/bin/ansible-interactive",
"dist": "yarn run clean-dist && yarn run make-dist-dirs && yarn run build && yarn run dist-js"
}
}
14 changes: 14 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

import json from 'rollup-plugin-json';
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';

export default {
input: 'src/index.js',
output: {
file: 'dist/ansible-interactive.js',
name: 'ansibleInteractive',
format: 'cjs'
},
plugins: [ commonjs(), resolve(), json() ]
};
52 changes: 33 additions & 19 deletions src/ansible-interactive.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const process = require('process');
const c = require('ansi-colors');
const args = require('./args');
const replay = require('./replay');
const loadInventory = require('./load-inventory');
Expand All @@ -11,24 +13,36 @@ const buildCommand = require('./build-command');
const runCommand = require('./run-command');

module.exports = async function() {
const replay_command = await replay();
if (replay_command) {
await runCommand(replay_command); // FIXME
try {
const replay_command = await replay();
if (replay_command) {
await runCommand(replay_command); // FIXME
}

const inventory = await loadInventory(args.inventory);
const groups = await loadGroups(inventory);
const playbook = await loadPlaybook(args.playbook);
const tags = await loadTags();
const mode = await loadMode();

const command = buildCommand({
inventory,
groups,
playbook,
tags,
mode,
});

await runCommand(command);
} catch (e) {
if (args.verbose) {
throw e;
}

console.error();
console.error(c.red(e));
console.error();

process.exit(1);
}

const inventory = await loadInventory(args.inventory);
const groups = await loadGroups(inventory);
const playbook = await loadPlaybook(args.playbook);
const tags = await loadTags();
const mode = await loadMode();

const command = buildCommand({
inventory,
groups,
playbook,
tags,
mode,
});

await runCommand(command);
};
3 changes: 0 additions & 3 deletions src/args.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
'use strict';

const pkg = require(`${__dirname}/../package.json`);

const args = require('yargs')
.usage('Usage: $0 [options]')
.version(pkg.version || 'beta')
.option('inventory', {
alias: 'i',
default: false,
Expand Down
8 changes: 4 additions & 4 deletions src/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ async function loadHistory() {

const history_file = historyFile();
fs.readFile(history_file, 'utf8', (err, data) => {
history = JSON.parse(data);
return err
? resolve([])
: resolve(history);
history = err
? []
: JSON.parse(data);
resolve(history);
});
});
}
Expand Down
3 changes: 0 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
'use strict';

// FIXME
require('process').chdir('/Users/inxilpro/Development/Sites/internachi/orchestration/ansible');

// Run
require('./ansible-interactive')();
16 changes: 11 additions & 5 deletions src/load-mode.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
'use strict';

const { prompt } = require('enquirer');
const c = require('ansi-colors');

module.exports = async function() {
const check = `Check mode (don't apply changes)`;
const live = `Live mode (WARNING - will apply changes)`;

const response = await prompt({
type: 'select',
name: 'mode',
message: `What mode would you like to run in?`,
choices: [
{
message: `Check mode (don't apply changes)`,
value: 'check',
message: c.green(check),
value: check,
}, {
message: `Live mode (WARNING - will apply changes)`,
value: 'live',
message: c.red(live),
value: live,
}
]
});

return response.mode;
return live === response.mode
? 'live'
: 'check';
};
2 changes: 1 addition & 1 deletion src/replay.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = async function() {
}

const last_command = history[0].filter(arg => '--check' !== arg);
const last_command_string = last_command.join(' ');
const last_command_string = last_command.join(' ').replace(' --diff', '');

const run_new = 'Run a new command';
const rerun_check = 'Re-run last command in check mode';
Expand Down
10 changes: 10 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ESNext",
"jsx": "react",
"importHelpers": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true
}
}
64 changes: 63 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ buffer@^3.0.1:
ieee754 "^1.1.4"
isarray "^1.0.0"

builtin-modules@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-2.0.0.tgz#60b7ef5ae6546bd7deefa74b08b62a43a232648e"

[email protected]:
version "3.0.0"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048"
Expand Down Expand Up @@ -749,6 +753,10 @@ estraverse@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13"

estree-walker@^0.5.2:
version "0.5.2"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.5.2.tgz#d3850be7529c9580d815600b53126515e146dd39"

esutils@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b"
Expand Down Expand Up @@ -1496,6 +1504,10 @@ is-glob@^2.0.0, is-glob@^2.0.1:
dependencies:
is-extglob "^1.0.0"

is-module@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591"

is-natural-number@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/is-natural-number/-/is-natural-number-4.0.1.tgz#ab9d76e1db4ced51e35de0c72ebecf09f734cde8"
Expand Down Expand Up @@ -1703,6 +1715,12 @@ lowercase-keys@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f"

magic-string@^0.25.1:
version "0.25.1"
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.1.tgz#b1c248b399cd7485da0fe7385c2fc7011843266e"
dependencies:
sourcemap-codec "^1.4.1"

make-dir@^1.0.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c"
Expand Down Expand Up @@ -1753,7 +1771,7 @@ methods@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"

micromatch@^2.1.5:
micromatch@^2.1.5, micromatch@^2.3.11:
version "2.3.11"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565"
dependencies:
Expand Down Expand Up @@ -2179,6 +2197,10 @@ path-key@^2.0.0, path-key@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"

path-parse@^1.0.5:
version "1.0.6"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"

[email protected]:
version "0.1.7"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c"
Expand Down Expand Up @@ -2437,6 +2459,12 @@ resolve-url@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"

resolve@^1.1.6, resolve@^1.8.1:
version "1.8.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26"
dependencies:
path-parse "^1.0.5"

[email protected]:
version "1.0.2"
resolved "https://registry.yarnpkg.com/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7"
Expand All @@ -2460,6 +2488,36 @@ rimraf@^2.6.1:
dependencies:
glob "^7.0.5"

rollup-plugin-commonjs@^9.2.0:
version "9.2.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-9.2.0.tgz#4604e25069e0c78a09e08faa95dc32dec27f7c89"
dependencies:
estree-walker "^0.5.2"
magic-string "^0.25.1"
resolve "^1.8.1"
rollup-pluginutils "^2.3.3"

rollup-plugin-json@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-json/-/rollup-plugin-json-3.1.0.tgz#7c1daf60c46bc21021ea016bd00863561a03321b"
dependencies:
rollup-pluginutils "^2.3.1"

rollup-plugin-node-resolve@^3.4.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.4.0.tgz#908585eda12e393caac7498715a01e08606abc89"
dependencies:
builtin-modules "^2.0.0"
is-module "^1.0.0"
resolve "^1.1.6"

rollup-pluginutils@^2.3.1, rollup-pluginutils@^2.3.3:
version "2.3.3"
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.3.3.tgz#3aad9b1eb3e7fe8262820818840bf091e5ae6794"
dependencies:
estree-walker "^0.5.2"
micromatch "^2.3.11"

rollup@^0.67.1:
version "0.67.1"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.67.1.tgz#4094110c944d3c9e25b5bf196771b51132ec3adb"
Expand Down Expand Up @@ -2653,6 +2711,10 @@ source-map@^0.7.1:
version "0.7.3"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"

sourcemap-codec@^1.4.1:
version "1.4.3"
resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.3.tgz#0ba615b73ec35112f63c2f2d9e7c3f87282b0e33"

split-string@^3.0.1, split-string@^3.0.2:
version "3.1.0"
resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
Expand Down

0 comments on commit 0ab05f2

Please sign in to comment.