@ollie-shop/cli 0.1.1 → 0.1.3
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/.turbo/turbo-build.log +3 -3
- package/CHANGELOG.md +13 -0
- package/dist/index.js +3 -7
- package/package.json +3 -2
- package/src/commands/login.ts +4 -17
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @ollie-shop/cli@0.1.
|
|
2
|
+
> @ollie-shop/cli@0.1.3 build /home/runner/work/ollie-shop/ollie-shop/packages/cli
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
[34mCLI[39m Target: esnext
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mCJS[39m Build start
|
|
12
|
-
[32mCJS[39m [1mdist/index.js [22m[32m7.
|
|
13
|
-
[32mCJS[39m ⚡️ Build success in
|
|
12
|
+
[32mCJS[39m [1mdist/index.js [22m[32m7.27 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 409ms
|
package/CHANGELOG.md
ADDED
package/dist/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var commander = require('commander');
|
|
5
|
-
var child_process = require('child_process');
|
|
6
5
|
var crypto = require('crypto');
|
|
7
6
|
var fs = require('fs/promises');
|
|
8
7
|
var http = require('http');
|
|
@@ -160,7 +159,7 @@ async function startWebAuthFlow(options) {
|
|
|
160
159
|
});
|
|
161
160
|
}
|
|
162
161
|
});
|
|
163
|
-
server.listen(port, () => {
|
|
162
|
+
server.listen(port, async () => {
|
|
164
163
|
const redirectUrl = `http://localhost:${port}/callback`;
|
|
165
164
|
const authUrl = new URL(baseUrl);
|
|
166
165
|
authUrl.searchParams.set("flow", "cli");
|
|
@@ -169,7 +168,8 @@ async function startWebAuthFlow(options) {
|
|
|
169
168
|
console.log("\n\u{1F512} Please authenticate in your browser...\n");
|
|
170
169
|
console.log(`Opening: ${authUrl}
|
|
171
170
|
`);
|
|
172
|
-
|
|
171
|
+
const open = (await import('open')).default;
|
|
172
|
+
open(authUrl.toString());
|
|
173
173
|
});
|
|
174
174
|
server.on("error", (err) => {
|
|
175
175
|
if (err.code === "EADDRINUSE") {
|
|
@@ -197,10 +197,6 @@ async function startWebAuthFlow(options) {
|
|
|
197
197
|
});
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
|
-
function openBrowser(url) {
|
|
201
|
-
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
202
|
-
child_process.spawn(command, [url], { detached: true }).unref();
|
|
203
|
-
}
|
|
204
200
|
async function saveCredentials(token) {
|
|
205
201
|
console.log("Saving credentials...");
|
|
206
202
|
const configDir = path__default.default.join(os.homedir(), ".ollie-shop");
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ollie-shop/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "CLI tools for Ollie Shop",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ollie-shop": "./dist/index.js"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"commander": "^11.1.0"
|
|
9
|
+
"commander": "^11.1.0",
|
|
10
|
+
"open": "^10.1.2"
|
|
10
11
|
},
|
|
11
12
|
"devDependencies": {
|
|
12
13
|
"@types/node": "^22.15.23",
|
package/src/commands/login.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
1
|
import { randomBytes } from "node:crypto";
|
|
3
2
|
import fs from "node:fs/promises";
|
|
4
3
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
@@ -244,7 +243,7 @@ async function startWebAuthFlow(options: {
|
|
|
244
243
|
});
|
|
245
244
|
|
|
246
245
|
// Start the server
|
|
247
|
-
server.listen(port, () => {
|
|
246
|
+
server.listen(port, async () => {
|
|
248
247
|
// Build the URL to your Next.js app with necessary parameters
|
|
249
248
|
const redirectUrl = `http://localhost:${port}/callback`;
|
|
250
249
|
|
|
@@ -257,8 +256,10 @@ async function startWebAuthFlow(options: {
|
|
|
257
256
|
console.log("\n🔒 Please authenticate in your browser...\n");
|
|
258
257
|
console.log(`Opening: ${authUrl}\n`);
|
|
259
258
|
|
|
259
|
+
const open = (await import("open")).default;
|
|
260
|
+
|
|
260
261
|
// Open the browser with the authorization URL
|
|
261
|
-
|
|
262
|
+
open(authUrl.toString());
|
|
262
263
|
});
|
|
263
264
|
|
|
264
265
|
// Handle server errors
|
|
@@ -293,20 +294,6 @@ async function startWebAuthFlow(options: {
|
|
|
293
294
|
});
|
|
294
295
|
}
|
|
295
296
|
|
|
296
|
-
/**
|
|
297
|
-
* Open the default browser with the given URL
|
|
298
|
-
*/
|
|
299
|
-
function openBrowser(url: string) {
|
|
300
|
-
const command =
|
|
301
|
-
process.platform === "darwin"
|
|
302
|
-
? "open"
|
|
303
|
-
: process.platform === "win32"
|
|
304
|
-
? "start"
|
|
305
|
-
: "xdg-open";
|
|
306
|
-
|
|
307
|
-
spawn(command, [url], { detached: true }).unref();
|
|
308
|
-
}
|
|
309
|
-
|
|
310
297
|
/**
|
|
311
298
|
* Save authentication credentials locally
|
|
312
299
|
*
|