@contrail/cli 1.0.0 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/.vscode/settings.json +5 -5
  2. package/bin/init +3 -3
  3. package/lib/{create-app → apps/create-app}/create.d.ts +1 -1
  4. package/lib/apps/create-app/create.js +59 -0
  5. package/lib/apps/create-app/setup-template.d.ts +1 -0
  6. package/lib/apps/create-app/setup-template.js +34 -0
  7. package/lib/{deploy-app → apps/deploy-app}/actions-deployer.d.ts +10 -10
  8. package/lib/{deploy-app → apps/deploy-app}/actions-deployer.js +97 -78
  9. package/lib/apps/deploy-app/app-deployer.d.ts +8 -0
  10. package/lib/{deploy-app → apps/deploy-app}/app-deployer.js +79 -58
  11. package/lib/apps/deploy-app/app-template-parsers.d.ts +7 -0
  12. package/lib/apps/deploy-app/app-template-parsers.js +37 -0
  13. package/lib/{deploy-app → apps/deploy-app}/deploy.d.ts +2 -2
  14. package/lib/apps/deploy-app/deploy.js +58 -0
  15. package/lib/apps/deploy-app/interfaces.d.ts +74 -0
  16. package/lib/apps/deploy-app/interfaces.js +4 -0
  17. package/lib/auth/auth.d.ts +9 -0
  18. package/lib/auth/auth.js +2 -0
  19. package/lib/auth/login.d.ts +2 -1
  20. package/lib/auth/login.js +113 -79
  21. package/lib/cli.d.ts +5 -5
  22. package/lib/cli.js +36 -30
  23. package/lib/common.d.ts +1 -0
  24. package/lib/common.js +5 -0
  25. package/lib/types/interfaces.d.ts +51 -0
  26. package/lib/{deploy-app → types}/interfaces.js +0 -0
  27. package/lib/types/option-set-uploader.d.ts +1 -0
  28. package/lib/types/option-set-uploader.js +75 -0
  29. package/lib/types/types-extractor.d.ts +1 -0
  30. package/lib/types/types-extractor.js +93 -0
  31. package/lib/types/types-uploader.d.ts +1 -0
  32. package/lib/types/types-uploader.js +171 -0
  33. package/package.json +63 -63
  34. package/publish.sh +5 -0
  35. package/src/apps/create-app/create.ts +73 -0
  36. package/src/apps/create-app/setup-template.ts +38 -0
  37. package/src/{deploy-app → apps/deploy-app}/actions-deployer.ts +122 -87
  38. package/src/{deploy-app → apps/deploy-app}/app-deployer.ts +86 -63
  39. package/src/apps/deploy-app/app-template-parsers.ts +43 -0
  40. package/src/apps/deploy-app/deploy.ts +67 -0
  41. package/src/apps/deploy-app/interfaces.ts +78 -0
  42. package/src/auth/auth.ts +10 -0
  43. package/src/auth/login.ts +127 -89
  44. package/src/cli.ts +38 -33
  45. package/src/common.ts +5 -0
  46. package/src/types/interfaces.ts +54 -0
  47. package/src/types/option-set-uploader.ts +83 -0
  48. package/src/types/types-extractor.ts +116 -0
  49. package/src/types/types-uploader.ts +198 -0
  50. package/templates/javascript/actions/example/action.js +37 -37
  51. package/templates/javascript/app.yml +54 -42
  52. package/templates/javascript/package.json +23 -23
  53. package/templates/typescript/actions/exampleAction.ts +38 -0
  54. package/templates/typescript/app.yml +56 -0
  55. package/templates/typescript/package.json +24 -0
  56. package/templates/typescript/tsconfig.json +31 -0
  57. package/tsconfig.json +30 -22
  58. package/tslint.json +57 -57
  59. package/lib/create-app/create.js +0 -48
  60. package/lib/create-app/setup-template.d.ts +0 -1
  61. package/lib/create-app/setup-template.js +0 -48
  62. package/lib/deploy-app/actions.d.ts +0 -5
  63. package/lib/deploy-app/actions.js +0 -17
  64. package/lib/deploy-app/app-declaration.d.ts +0 -20
  65. package/lib/deploy-app/app-declaration.js +0 -0
  66. package/lib/deploy-app/app-deployer.d.ts +0 -9
  67. package/lib/deploy-app/app.d.ts +0 -8
  68. package/lib/deploy-app/app.js +0 -56
  69. package/lib/deploy-app/deploy.js +0 -30
  70. package/lib/deploy-app/interfaces.d.ts +0 -34
  71. package/src/create-app/create.ts +0 -58
  72. package/src/create-app/setup-template.ts +0 -61
  73. package/src/deploy-app/deploy.ts +0 -34
  74. package/src/deploy-app/interfaces.ts +0 -35
@@ -1,61 +0,0 @@
1
-
2
- import ncp from 'ncp';
3
- import path from 'path';
4
- import { promisify } from 'util';
5
- import execa from 'execa';
6
- const Listr = require('listr');
7
- import { projectInstall } from 'pkg-install';
8
- const copy = promisify(ncp);
9
- const TARGET_DIR = process.cwd();
10
-
11
- const currentFileUrl = import .meta.url;
12
- const TEMPLATE_DIR = path.resolve(
13
- new URL(currentFileUrl).pathname,
14
- '../../../templates/javascript',
15
- ).replace(/\\/g, '\\').replace(/C:\\C:/g, '');
16
-
17
- // console.log("TEMPLATE_DIR: ", TEMPLATE_DIR)
18
- // console.log("TARGET_DIR: ", TARGET_DIR)
19
-
20
- function copyTemplate(){
21
- return copy(TEMPLATE_DIR, TARGET_DIR, {
22
- clobber: false,
23
- });
24
- }
25
-
26
- function npmInstall(){
27
- async function initGit(options) {
28
- const result = await execa('git', ['init'], {
29
- cwd: options.targetDirectory,
30
- });
31
- if (result.failed) {
32
- return Promise.reject(new Error('Failed to initialize git'));
33
- }
34
- return;
35
- }
36
- }
37
-
38
- export async function setUpTemplate() {
39
- try {
40
- const tasks = new Listr([
41
- {
42
- title: 'Copy template files',
43
- task: () => copyTemplate(),
44
- },
45
- {
46
- title: 'Install dependencies',
47
- task: () =>
48
- projectInstall({
49
- cwd: TARGET_DIR,
50
- }),
51
- // skip: () =>
52
- // !options.runInstall
53
- // ? 'Pass --install to automatically install dependencies'
54
- // : undefined,
55
- },
56
- ]);
57
- await tasks.run();
58
- } catch (e) {
59
- console.log('Error copying template: ', e);
60
- }
61
- }
@@ -1,34 +0,0 @@
1
- import chalk from 'chalk';
2
- import fs from 'fs';
3
- import { authUser } from '../auth/login';
4
- import { AppDeployer } from './app-deployer';
5
- import { AppDeclartion } from './interfaces';
6
- const yaml = require('js-yaml');
7
-
8
- function loadAppConfig(){
9
- const TARGET_DIR = process.cwd();
10
- try {
11
- const doc = yaml.load(fs.readFileSync(TARGET_DIR + '/app.yml', 'utf8'));
12
- console.log(doc);
13
- return doc;
14
- } catch (e) {
15
- console.log('ERROR PARSING YAML: ', e);
16
- }
17
- }
18
-
19
- export async function deployApp(args) {
20
- const appDeclaration: AppDeclartion = loadAppConfig();
21
-
22
- console.log(`%s Deploying application. ${appDeclaration.appIdentifier}`, chalk.blue.bold('START'));
23
- const user = await authUser();
24
- await new AppDeployer().deploy(appDeclaration);
25
- console.log('%s Deployment complete.', chalk.green.bold('COMPLETE'));
26
- }
27
-
28
- export async function removeApp(args) {
29
- const appDeclaration: AppDeclartion = loadAppConfig();
30
- console.log(`%s Removing application. ${appDeclaration.appIdentifier}`, chalk.blue.bold('START'));
31
- await authUser();
32
- await new AppDeployer().remove(appDeclaration);
33
- console.log('%s Removing complete.', chalk.green.bold('COMPLETE'));
34
- }
@@ -1,35 +0,0 @@
1
- /** Describes the derivative JSON / object represented
2
- * in app.yml file.
3
- */
4
- export interface AppDeclartion {
5
- appIdentifier: string;
6
- appName: string;
7
- appDescription?: string;
8
- visibility: 'private' | 'public';
9
- publisher: string;
10
- version: string;
11
- thumbnail?: string;
12
- actions?: { [key: string]: AppActionDeclaration };
13
- }
14
-
15
- export interface AppActionDeclaration {
16
- handler: string;
17
- name: string;
18
- description?: string;
19
- }
20
-
21
- export interface App {
22
- id: string;
23
- identifier: string;
24
- name: string;
25
- private: boolean;
26
- }
27
-
28
- export interface EventWorkflowActionDefinition {
29
- id?: string;
30
- identifier?: string;
31
- name?: string;
32
- executeFunctionString?: string;
33
- ownerKey?: string;
34
- public?: boolean;
35
- }