Skip to content

Commit ef500fd

Browse files
Merge pull request #121 from godspeedsystems/fix/ora
Remove ora Dependency
2 parents 6fcdf20 + 4a9ba9e commit ef500fd

6 files changed

Lines changed: 76 additions & 141 deletions

File tree

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"js-yaml": "^4.1.0",
3737
"lodash": "^4.17.21",
3838
"mocha": "^10.2.0",
39-
"ora": "^8.2.0",
4039
"path": "^0.12.7",
4140
"pino-pretty": "^10.2.0",
4241
"proxyquire": "^2.1.3",

src/commands/devops-plugin/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ const installAction = async (gsDevOpsPlugin: string) => {
1818
}
1919

2020
if (!existsSync(path.join(gsDevopsPluginsDir, "package.json"))) {
21-
spawnSync("npm", ["init", "--yes"], { cwd: gsDevopsPluginsDir });
21+
spawnSync("pnpm", ["init"], { cwd: gsDevopsPluginsDir, stdio: 'ignore' });
2222
}
2323

2424
// npm install <gsDevOpsPlugin> in the <gsDevopsPluginsDir> directory
25-
spawnSync("npm", ["i", `${gsDevOpsPlugin}`], {
25+
spawnSync("pnpm", ["add", `${gsDevOpsPlugin}`], {
2626
cwd: gsDevopsPluginsDir,
2727
stdio: "inherit",
2828
});
@@ -69,8 +69,8 @@ const list = program
6969
} else {
7070
// fetch the list of packages, maybe from the plugins repository
7171
let npmSearch = spawnSync(
72-
"npm",
73-
["search", `@godspeedsystems/devops-plugin`, "--json"],
72+
"pnpm",
73+
["search", "--json", `@godspeedsystems/devops-plugin`],
7474
{ encoding: "utf-8" }
7575
);
7676
let availablePlugins:
@@ -149,7 +149,7 @@ const remove = program
149149
]);
150150

151151
// uninstallDevOpsPlugin(answer.gsDevOpsPlugin)
152-
spawnSync("npm", ["uninstall", `${answer.gsDevOpsPlugin}`], {
152+
spawnSync("pnpm", ["remove", `${answer.gsDevOpsPlugin}`], {
153153
cwd: gsDevopsPluginsDir,
154154
stdio: "inherit",
155155
});
@@ -195,7 +195,7 @@ const update = program
195195
]);
196196

197197
// npm install <gsDevOpsPlugin> in the <gsDevopsPluginsDir> directory
198-
spawnSync("npm", ["install", `${answer.gsDevOpsPlugin}@latest`], {
198+
spawnSync("pnpm", ["add", `${answer.gsDevOpsPlugin}@latest`], {
199199
cwd: gsDevopsPluginsDir,
200200
stdio: "inherit",
201201
});

src/commands/otel/index.ts

Lines changed: 34 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,29 @@ import spawnSync from "cross-spawn";
33
import path from "path";
44
import { readFile, writeFile } from "fs/promises"
55
import fs from "fs";
6-
import ora from 'ora';
7-
// const projectDirPath = path.resolve(process.cwd(), projectName);
8-
96
const program = new Command();
10-
const spinner = ora({
11-
text: 'Installing packages... ',
12-
spinner: {
13-
frames: ['🌍 ', '🌎 ', '🌏 ', '🌐 ', '🌑 ', '🌒 ', '🌓 ', '🌔 '],
14-
interval: 180,
15-
},
16-
});
177

188
const enableAction = async () => {
199
// install that package
20-
async function installtracing(tracing:any) {
21-
try {
22-
spinner.start();
23-
24-
const child = spawnSync('npm', ['install', `${tracing}`, '--quiet', '--no-warnings', '--silent', '--progress=false'], {
25-
stdio: 'inherit',
26-
});
27-
28-
await new Promise<void>((resolve) => {
29-
child.on('close', () => {
30-
resolve();
31-
});
10+
async function installtracing(tracing: string) {
11+
console.log(`Installing ${tracing}...`);
12+
try {
13+
const child = spawnSync('pnpm', ['add', tracing, '--reporter=silent'], {
14+
stdio: 'inherit',
15+
});
16+
17+
await new Promise<void>((resolve) => {
18+
child.on('close', () => {
19+
resolve();
3220
});
33-
34-
spinner.stop();
35-
console.log('\notel installed successfully!');
36-
} catch (error:any) {
37-
spinner.stop();
38-
console.error('Error during installation:', error.message);
39-
}
21+
});
22+
23+
console.log('\nOpenTelemetry installed successfully!');
24+
} catch (error: any) {
25+
console.error('Error during installation:', error.message);
26+
throw error;
4027
}
28+
}
4129

4230
// Call the installPlugin function
4331
try {
@@ -67,28 +55,25 @@ const enableAction = async () => {
6755

6856
const disableAction = async () => {
6957
// uninstall that package
70-
async function uninstalltracing(tracing:any) {
71-
try {
72-
spinner.start();
73-
74-
// Use spawnCommand instead of spawnSync
75-
const child = spawnSync('npm', ['uninstall', `${tracing}`, '--quiet', '--no-warnings', '--silent', '--progress=false'], {
76-
stdio: 'inherit', // Redirect output
77-
});
78-
79-
await new Promise<void>((resolve) => {
80-
child.on('close', () => {
81-
resolve();
82-
});
58+
async function uninstalltracing(tracing: string) {
59+
console.log(`Uninstalling ${tracing}...`);
60+
try {
61+
const child = spawnSync('pnpm', ['remove', tracing], {
62+
stdio: 'inherit',
63+
});
64+
65+
await new Promise<void>((resolve) => {
66+
child.on('close', () => {
67+
resolve();
8368
});
84-
85-
spinner.stop();
86-
console.log('\notel uninstalled successfully!');
87-
} catch (error:any) {
88-
spinner.stop();
89-
console.error('Error during uninstallation:', error.message);
90-
}
69+
});
70+
71+
console.log('\nOpenTelemetry uninstalled successfully!');
72+
} catch (error: any) {
73+
console.error('Error during uninstallation:', error.message);
74+
throw error;
9175
}
76+
}
9277

9378
// Call the uninstallPlugin function
9479

src/commands/plugin/index.ts

Lines changed: 19 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import inquirer from "inquirer";
1313
import * as yaml from "js-yaml";
1414
import { cwd } from "process";
1515
import chalk from "chalk";
16-
import ora from "ora";
1716

1817
const pluginsFilePath = path.resolve(__dirname, '../../../pluginsList.json');
1918
if (!fs.existsSync(pluginsFilePath)) {
@@ -176,14 +175,7 @@ export default EventSource;
176175
}
177176

178177
const addAction = async (pluginsList: string[]) => {
179-
const spinner = ora({
180-
text: "Installing plugins... ",
181-
spinner: {
182-
frames: ["🌍 ", "🌎 ", "🌏 ", "🌐 ", "🌑 ", "🌒 ", "🌓 ", "🌔 "],
183-
interval: 180,
184-
},
185-
});
186-
178+
console.log('Searching for plugin...');
187179
async function installPlugin(pluginsList: string[]) {
188180
try {
189181
console.log("Starting plugin installation...");
@@ -193,19 +185,9 @@ const addAction = async (pluginsList: string[]) => {
193185

194186
const packageManager = hasPnpm ? "pnpm" : "npm";
195187
console.log(`Using package manager: ${packageManager}`);
196-
197-
spinner.text = `Installing plugins with ${packageManager}...`;
198-
spinner.start();
199-
188+
console.log(`Installing plugins with ${packageManager}...`);
200189
const startTime = Date.now();
201-
let dots = 0;
202190

203-
const intervalId = setInterval(() => {
204-
dots = (dots + 1) % 4;
205-
const elapsed = Math.floor((Date.now() - startTime) / 1000);
206-
spinner.text = `Installing plugins with ${packageManager}${'.'.repeat(dots)} (${elapsed}s elapsed)`;
207-
}, 1000);
208-
209191
return new Promise<void>((resolve, reject) => {
210192
const { exec } = require('child_process');
211193

@@ -237,26 +219,24 @@ const addAction = async (pluginsList: string[]) => {
237219
});
238220

239221
childProcess.on('exit', (code: number) => {
240-
clearInterval(intervalId);
241-
242222
if (code !== 0) {
243-
spinner.stop();
223+
244224
console.error(`Installation failed with exit code: ${code}`);
245225
console.error("Error output:", stderrData || "No error output");
246226
reject(new Error(`Process exited with code ${code}`));
247227
return;
248228
}
249229

250230
const totalTime = ((Date.now() - startTime) / 1000).toFixed(1);
251-
spinner.stop();
252-
console.log(`\nPlugins installed successfully in ${totalTime}s!`);
231+
232+
console.log(`\n✓ All plugins installed successfully in ${totalTime}s!`);
253233
console.log(`Installed plugins: ${pluginsList.join(', ')}`);
254234
console.log(chalk.cyan.bold("Happy coding with Godspeed! 🚀🎉\n"));
255235
resolve();
256236
});
257237
});
258238
} catch (error: any) {
259-
spinner.stop();
239+
260240
console.error("Error during installation:", error.message);
261241
throw error;
262242
}
@@ -525,26 +505,16 @@ const add = program
525505
});
526506

527507
const removeAction = async (pluginsList: string[]) => {
528-
const spinner = ora({
529-
text: "Uninstalling plugins... ",
530-
spinner: {
531-
frames: ["🌍 ", "🌎 ", "🌏 ", "🌐 ", "🌑 ", "🌒 ", "🌓 ", "🌔 "],
532-
interval: 180,
533-
},
534-
});
535508
async function uninstallPlugin(pluginsList: string[]) {
536509
try {
537-
spinner.start();
538-
510+
console.log("Uninstalling plugins...");
511+
539512
const child = spawnSync(
540-
"npm",
513+
"pnpm",
541514
[
542-
"uninstall",
515+
"remove",
543516
...pluginsList,
544-
"--quiet",
545-
"--no-warnings",
546-
"--silent",
547-
"--progress=false",
517+
"--reporter=silent"
548518
],
549519
{
550520
stdio: "inherit",
@@ -557,11 +527,11 @@ const removeAction = async (pluginsList: string[]) => {
557527
});
558528
});
559529

560-
spinner.stop();
530+
561531
console.log("\nPlugins uninstalled successfully!");
562532
console.log(chalk.cyan.bold("Happy coding with Godspeed! 🚀🎉\n"));
563533
} catch (error: any) {
564-
spinner.stop();
534+
565535
console.error("Error during installation:", error.message);
566536
}
567537
}
@@ -742,26 +712,16 @@ const update = program
742712
return;
743713
}
744714

745-
const spinner = ora({
746-
text: "Updating plugins... ",
747-
spinner: {
748-
frames: ["🌍 ", "🌎 ", "🌏 ", "🌐 ", "🌑 ", "🌒 ", "🌓 ", "🌔 "],
749-
interval: 180,
750-
},
751-
});
752715
async function updatePlugin(pluginsList: string[]) {
753716
try {
754-
spinner.start();
755-
717+
console.log("Updating plugins...");
718+
756719
const child = spawnSync(
757-
"npm",
720+
"pnpm",
758721
[
759722
"update",
760723
...pluginsList,
761-
"--quiet",
762-
"--no-warnings",
763-
"--silent",
764-
"--progress=false",
724+
"--reporter=silent"
765725
],
766726
{
767727
stdio: "inherit",
@@ -774,11 +734,11 @@ const update = program
774734
});
775735
});
776736

777-
spinner.stop();
737+
778738
console.log("\nPlugins updated successfully!");
779739
console.log(chalk.cyan.bold("Happy coding with Godspeed! 🚀🎉\n"));
780740
} catch (error: any) {
781-
spinner.stop();
741+
782742
console.error("Error during updation:", error.message);
783743
}
784744
}

src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ const updateServicesJson = async (add = true) => {
211211
.description("run godspeed development server.")
212212
.action(async () => {
213213
if (await isAGodspeedProject()) {
214-
spawnSync("npm", ["run", "dev"], {
214+
spawnSync("pnpm", ["run", "dev"], {
215215
stdio: "inherit",
216216
});
217217
}
@@ -222,7 +222,7 @@ const updateServicesJson = async (add = true) => {
222222
.description(`clean the previous build.`)
223223
.action(async (options) => {
224224
if (isAGodspeedProject()) {
225-
spawnSync("npm", ["run", "clean"], {
225+
spawnSync("pnpm", ["run", "clean"], {
226226
stdio: "inherit",
227227
});
228228
}
@@ -253,7 +253,7 @@ const updateServicesJson = async (add = true) => {
253253
)
254254
.action(async () => {
255255
if (isAGodspeedProject()) {
256-
spawnSync("npm", ["run", "gen-crud-api"], { stdio: "inherit" });
256+
spawnSync("pnpm", ["run", "gen-crud-api"], { stdio: "inherit" });
257257
}
258258
});
259259
program
@@ -271,7 +271,7 @@ const updateServicesJson = async (add = true) => {
271271
.description("build the godspeed project. create a production build.")
272272
.action(async (options) => {
273273
if (await isAGodspeedProject()) {
274-
spawnSync("npm", ["run", "build"], {
274+
spawnSync("pnpm", ["run", "build"], {
275275
stdio: "inherit",
276276
env: {
277277
// NODE_ENV: "production",
@@ -285,7 +285,7 @@ const updateServicesJson = async (add = true) => {
285285
.description("preview the production build.")
286286
.action(async (options) => {
287287
if (await isAGodspeedProject()) {
288-
spawnSync("npm", ["run", "preview"], {
288+
spawnSync("pnpm", ["run", "preview"], {
289289
stdio: "inherit",
290290
env: {
291291
// NODE_ENV: "production",
@@ -352,7 +352,7 @@ const updateServicesJson = async (add = true) => {
352352
.description("build and preview the production build in watch mode.")
353353
.action(async (options) => {
354354
if (await isAGodspeedProject()) {
355-
spawnSync("npm", ["run", "serve"], {
355+
spawnSync("pnpm", ["run", "serve"], {
356356
stdio: "inherit",
357357
env: {
358358
// NODE_ENV: "production",

0 commit comments

Comments
 (0)