@myop/cli 0.1.3 → 0.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myop/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Myop cli",
5
5
  "type": "module",
6
6
  "repository": {
@@ -20,12 +20,11 @@
20
20
  "dist"
21
21
  ],
22
22
  "bin": {
23
- "myop": "./dist/myop-cli.js",
24
- "myopd": "./src/myop-cli.js"
23
+ "myop": "./dist/myop-cli.js"
25
24
  },
26
25
  "scripts": {
27
26
  "try": "myop",
28
- "build": "vite build && chmod +x ./dist/myop-cli.js",
27
+ "build": "vite build && chmod +x ./dist/myop-cli.js && mkdir -p ./dist/commands/dev/management-website && cp -R ./src/commands/dev/management-website/* ./dist/commands/dev/management-website/",
29
28
  "release": "npm publish --access public",
30
29
  "cpTemplates": "cp -R ./node_modules/@myop/code-generator/dist/templates ./public"
31
30
  },
@@ -35,7 +34,6 @@
35
34
  },
36
35
  "dependencies": {
37
36
  "@inquirer/prompts": "^6.0.1",
38
- "@myop/cli": "^0.0.3",
39
37
  "commander": "^12.1.0",
40
38
  "ora": "^8.1.0",
41
39
  "ts-morph": "^24.0.0"
package/src/myop-cli.js DELETED
@@ -1,157 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import ora from 'ora';
4
- import {select, Separator} from '@inquirer/prompts';
5
- import {Command, Option} from 'commander';
6
- import {helpPrompt} from "./helpPrompt.js";
7
- import * as operations from './operations/index.js';
8
- import {State} from "./cliState.js";
9
- import {readMyopConfigFile, writeMyopConfigFile} from "./common/myopConfigFile.js";
10
-
11
- const wait = (t) => new Promise(resolve => setTimeout(resolve, t));
12
- const clearConsole = () => {
13
- process.stdout.write('\x1Bc')
14
- }
15
-
16
- State.executionPath = process.cwd();
17
-
18
- const loadCliState = (createNewConfig = false) => {
19
- const verbose = State.program.getOptionValue('verbose');
20
-
21
- if (!verbose) {
22
- console.info = () => {
23
- };
24
- }
25
- console.info("📝 verbose mode on");
26
-
27
- State.options = {
28
- configPath: State.program.getOptionValue('config'),
29
- verbose
30
- };
31
-
32
- try {
33
- State.myopConfig = readMyopConfigFile(State.options.configPath);
34
- } catch (parseError) {
35
-
36
- if (createNewConfig) {
37
- console.info(`\n⚠️ failed read config file from ${State.options.configPath}, trying to create new one`);
38
-
39
- try {
40
- const emptyConfigFile = {
41
- author: "@myop-cli",
42
- flows: []
43
- };
44
-
45
- writeMyopConfigFile(State.options.configPath, emptyConfigFile);
46
- State.myopConfig = emptyConfigFile;
47
- } catch (writingError) {
48
- console.log(`\n⚠️ failed read config file from ${State.options.configPath}, for more details use verbose flag`);
49
- console.info(`Error details :`, parseError);
50
- process.exit();
51
- }
52
- } else {
53
- console.log(`\n⚠️ failed read config file from ${State.options.configPath}, for more details use verbose flag`);
54
- console.info(`Error details :`, parseError);
55
- process.exit();
56
- }
57
- }
58
- }
59
-
60
- const operationsMenu = [
61
- operations.myopInstall,
62
- operations.addFlow,
63
- operations.removeFlow,
64
- operations.quit,
65
- new Separator(),
66
- ...operations.disabledOperations
67
- ];
68
-
69
- const displayOperations = async () => {
70
- return select({
71
- message: 'Select an operation',
72
- choices: operationsMenu
73
- });
74
- }
75
-
76
- const askForOperation = async () => {
77
- const operationName = await displayOperations();
78
- const operation = operationsMenu.find(operation => operation.value === operationName);
79
-
80
- if (!operation) {
81
- console.log(`⚠️ Operation ${operationName} not found`);
82
- } else if (!operation.action) {
83
- console.log(`⚠️ Operation ${operationName} has no action`);
84
- } else {
85
- await operation.action();
86
- }
87
-
88
- await askForOperation();
89
- }
90
-
91
- State.program = new Command();
92
- State.program
93
- .name('@myop/cli')
94
- .description('Myop CLI - Remote UI Made Easy')
95
- .version('0.0.55');
96
-
97
- State.program.addOption(new Option('-c, --config <value>', 'myop.config.json file location').default('./myop.config.json', './myop.config.json'));
98
- State.program.addOption(new Option('-h, --help', 'Show helpful information'));
99
- State.program.addOption(new Option('-v, --verbose', 'Enables verbose output mode for the command-line interface (CLI).'));
100
-
101
- State.program.command('add')
102
- .description('Install Myop assets')
103
- .addArgument('type')
104
- .addArgument('id')
105
- .action((type, id) => {
106
- loadCliState(true);
107
-
108
- console.info('adding ', type, id, State.options.configPath);
109
- if (type === "flow")
110
- operations.addFlow._action(id);
111
-
112
- process.exit()
113
- });
114
-
115
- State.program.command('remove')
116
- .description('Remove Myop asset')
117
- .argument('<type>', 'Myop asset type')
118
- .argument('<id>', 'Asset id')
119
- .action((type, id) => {
120
- loadCliState();
121
-
122
- console.info('removing ', type, id, State.options.configPath);
123
- if (type === "flow")
124
- operations.removeFlow._action(id);
125
- process.exit()
126
- });
127
-
128
- State.program.command('install')
129
- .description('Install Myop assets')
130
- .action(async () => {
131
- loadCliState();
132
- await operations.myopInstall.action()
133
- });
134
-
135
- State.program.command('default', {isDefault: true})
136
- .action(async () => {
137
-
138
- const help = State.program.getOptionValue('help');
139
- if (help) {
140
- console.log(helpPrompt);
141
- process.exit()
142
- }
143
-
144
- let spinner = ora({
145
- text: 'Loading Myop CLI...',
146
- color: 'green'
147
- }).start();
148
-
149
- loadCliState();
150
- await wait(1000);
151
- spinner.succeed('Myop CLI Loaded')
152
-
153
- await askForOperation();
154
- });
155
-
156
- State.program.parse(process.argv);
157
- const options = State.program.opts();