@cloud-copilot/cli 0.1.18 → 0.1.20
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/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/readRelative.d.ts +17 -0
- package/dist/cjs/readRelative.d.ts.map +1 -0
- package/dist/cjs/readRelative.js +38 -0
- package/dist/cjs/readRelative.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/readRelative.d.ts +17 -0
- package/dist/esm/readRelative.d.ts.map +1 -0
- package/dist/esm/readRelative.js +35 -0
- package/dist/esm/readRelative.js.map +1 -0
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,MAAM,EACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,MAAM,EACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readStdin = exports.printHelpContents = exports.parseCliArguments = void 0;
|
|
3
|
+
exports.readStdin = exports.readRelativeFile = exports.printHelpContents = exports.parseCliArguments = void 0;
|
|
4
4
|
var cli_js_1 = require("./cli.js");
|
|
5
5
|
Object.defineProperty(exports, "parseCliArguments", { enumerable: true, get: function () { return cli_js_1.parseCliArguments; } });
|
|
6
6
|
Object.defineProperty(exports, "printHelpContents", { enumerable: true, get: function () { return cli_js_1.printHelpContents; } });
|
|
7
|
+
var readRelative_js_1 = require("./readRelative.js");
|
|
8
|
+
Object.defineProperty(exports, "readRelativeFile", { enumerable: true, get: function () { return readRelative_js_1.readRelativeFile; } });
|
|
7
9
|
var stdin_js_1 = require("./stdin.js");
|
|
8
10
|
Object.defineProperty(exports, "readStdin", { enumerable: true, get: function () { return stdin_js_1.readStdin; } });
|
|
9
11
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAKiB;AAJf,2GAAA,iBAAiB,OAAA;AACjB,2GAAA,iBAAiB,OAAA;AAInB,uCAAsC;AAA7B,qGAAA,SAAS,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAKiB;AAJf,2GAAA,iBAAiB,OAAA;AACjB,2GAAA,iBAAiB,OAAA;AAInB,qDAAoD;AAA3C,mHAAA,gBAAgB,OAAA;AACzB,uCAAsC;AAA7B,qGAAA,SAAS,OAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A relatively sane way to read a file from a relative path inside your packaged cli app. For instance to
|
|
3
|
+
* read the package.json inside your package. Works on ESM and CommonJS modules. Use __filename
|
|
4
|
+
* or import.meta.url to get the path of the file you are in and pass it to this function. Set the `levelsUp`
|
|
5
|
+
* based on how your project is packaged. For instance, if your file is packaged in `dist/cli.js` and you would use `1` if
|
|
6
|
+
* you packaged your file is in `dist/src/cli.js` and you would use `2`. Whatever you need to get to the root.
|
|
7
|
+
* Then the path parts are the path to the file you want to read, relative to the root of your project with each
|
|
8
|
+
* directory as a separate string in the array and the file name as the last string in the array. They will be
|
|
9
|
+
* joined together in a way that makes sense for the OS and module type your package is running in.
|
|
10
|
+
*
|
|
11
|
+
* @param currentFile the path to start from use `import.meta.url` or `__filename` for most cases
|
|
12
|
+
* @param levelsUp since __import.meta.url or __filename is the file you are in, you need to go up a few levels to ge to the root of your project. Use 0 for the current directory of the file you're calling from.
|
|
13
|
+
* @param pathParts the path to the file, relative to the new root
|
|
14
|
+
* @returns the contents of the file as a string
|
|
15
|
+
*/
|
|
16
|
+
export declare function readRelativeFile(currentFile: string, levelsUp: number, pathParts: string[]): Promise<string>;
|
|
17
|
+
//# sourceMappingURL=readRelative.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readRelative.d.ts","sourceRoot":"","sources":["../../src/readRelative.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC,MAAM,CAAC,CAgBjB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readRelativeFile = readRelativeFile;
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
/**
|
|
7
|
+
* A relatively sane way to read a file from a relative path inside your packaged cli app. For instance to
|
|
8
|
+
* read the package.json inside your package. Works on ESM and CommonJS modules. Use __filename
|
|
9
|
+
* or import.meta.url to get the path of the file you are in and pass it to this function. Set the `levelsUp`
|
|
10
|
+
* based on how your project is packaged. For instance, if your file is packaged in `dist/cli.js` and you would use `1` if
|
|
11
|
+
* you packaged your file is in `dist/src/cli.js` and you would use `2`. Whatever you need to get to the root.
|
|
12
|
+
* Then the path parts are the path to the file you want to read, relative to the root of your project with each
|
|
13
|
+
* directory as a separate string in the array and the file name as the last string in the array. They will be
|
|
14
|
+
* joined together in a way that makes sense for the OS and module type your package is running in.
|
|
15
|
+
*
|
|
16
|
+
* @param currentFile the path to start from use `import.meta.url` or `__filename` for most cases
|
|
17
|
+
* @param levelsUp since __import.meta.url or __filename is the file you are in, you need to go up a few levels to ge to the root of your project. Use 0 for the current directory of the file you're calling from.
|
|
18
|
+
* @param pathParts the path to the file, relative to the new root
|
|
19
|
+
* @returns the contents of the file as a string
|
|
20
|
+
*/
|
|
21
|
+
async function readRelativeFile(currentFile, levelsUp, pathParts) {
|
|
22
|
+
const isEsm = currentFile.startsWith('file://');
|
|
23
|
+
const backSegments = Array(levelsUp).fill('..');
|
|
24
|
+
if (isEsm) {
|
|
25
|
+
const dirPath = currentFile.slice(0, currentFile.lastIndexOf('/'));
|
|
26
|
+
const { fileURLToPath } = await Promise.resolve().then(() => require('node:url'));
|
|
27
|
+
const { join } = await Promise.resolve().then(() => require('node:path'));
|
|
28
|
+
const startPath = fileURLToPath(dirPath);
|
|
29
|
+
const fullPath = join(startPath, ...backSegments, ...pathParts);
|
|
30
|
+
return await (0, promises_1.readFile)(fullPath, 'utf8');
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const dirPath = currentFile.slice(0, currentFile.lastIndexOf(path_1.sep));
|
|
34
|
+
const contents = await (0, promises_1.readFile)((0, path_1.join)(dirPath, ...backSegments, ...pathParts), 'utf8');
|
|
35
|
+
return contents;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=readRelative.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readRelative.js","sourceRoot":"","sources":["../../src/readR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ot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,MAAM,EACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,MAAM,EACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EAGlB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EAGlB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A relatively sane way to read a file from a relative path inside your packaged cli app. For instance to
|
|
3
|
+
* read the package.json inside your package. Works on ESM and CommonJS modules. Use __filename
|
|
4
|
+
* or import.meta.url to get the path of the file you are in and pass it to this function. Set the `levelsUp`
|
|
5
|
+
* based on how your project is packaged. For instance, if your file is packaged in `dist/cli.js` and you would use `1` if
|
|
6
|
+
* you packaged your file is in `dist/src/cli.js` and you would use `2`. Whatever you need to get to the root.
|
|
7
|
+
* Then the path parts are the path to the file you want to read, relative to the root of your project with each
|
|
8
|
+
* directory as a separate string in the array and the file name as the last string in the array. They will be
|
|
9
|
+
* joined together in a way that makes sense for the OS and module type your package is running in.
|
|
10
|
+
*
|
|
11
|
+
* @param currentFile the path to start from use `import.meta.url` or `__filename` for most cases
|
|
12
|
+
* @param levelsUp since __import.meta.url or __filename is the file you are in, you need to go up a few levels to ge to the root of your project. Use 0 for the current directory of the file you're calling from.
|
|
13
|
+
* @param pathParts the path to the file, relative to the new root
|
|
14
|
+
* @returns the contents of the file as a string
|
|
15
|
+
*/
|
|
16
|
+
export declare function readRelativeFile(currentFile: string, levelsUp: number, pathParts: string[]): Promise<string>;
|
|
17
|
+
//# sourceMappingURL=readRelative.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readRelative.d.ts","sourceRoot":"","sources":["../../src/readRelative.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC,MAAM,CAAC,CAgBjB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { readFile } from 'fs/promises';
|
|
2
|
+
import { join, sep } from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* A relatively sane way to read a file from a relative path inside your packaged cli app. For instance to
|
|
5
|
+
* read the package.json inside your package. Works on ESM and CommonJS modules. Use __filename
|
|
6
|
+
* or import.meta.url to get the path of the file you are in and pass it to this function. Set the `levelsUp`
|
|
7
|
+
* based on how your project is packaged. For instance, if your file is packaged in `dist/cli.js` and you would use `1` if
|
|
8
|
+
* you packaged your file is in `dist/src/cli.js` and you would use `2`. Whatever you need to get to the root.
|
|
9
|
+
* Then the path parts are the path to the file you want to read, relative to the root of your project with each
|
|
10
|
+
* directory as a separate string in the array and the file name as the last string in the array. They will be
|
|
11
|
+
* joined together in a way that makes sense for the OS and module type your package is running in.
|
|
12
|
+
*
|
|
13
|
+
* @param currentFile the path to start from use `import.meta.url` or `__filename` for most cases
|
|
14
|
+
* @param levelsUp since __import.meta.url or __filename is the file you are in, you need to go up a few levels to ge to the root of your project. Use 0 for the current directory of the file you're calling from.
|
|
15
|
+
* @param pathParts the path to the file, relative to the new root
|
|
16
|
+
* @returns the contents of the file as a string
|
|
17
|
+
*/
|
|
18
|
+
export async function readRelativeFile(currentFile, levelsUp, pathParts) {
|
|
19
|
+
const isEsm = currentFile.startsWith('file://');
|
|
20
|
+
const backSegments = Array(levelsUp).fill('..');
|
|
21
|
+
if (isEsm) {
|
|
22
|
+
const dirPath = currentFile.slice(0, currentFile.lastIndexOf('/'));
|
|
23
|
+
const { fileURLToPath } = await import('node:url');
|
|
24
|
+
const { join } = await import('node:path');
|
|
25
|
+
const startPath = fileURLToPath(dirPath);
|
|
26
|
+
const fullPath = join(startPath, ...backSegments, ...pathParts);
|
|
27
|
+
return await readFile(fullPath, 'utf8');
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const dirPath = currentFile.slice(0, currentFile.lastIndexOf(sep));
|
|
31
|
+
const contents = await readFile(join(dirPath, ...backSegments, ...pathParts), 'utf8');
|
|
32
|
+
return contents;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=readRelative.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readRelative.js","sourceRoot":"","sources":["../../src/readRelative.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAEhC;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,WAAmB,EACnB,QAAgB,EAChB,SAAmB;I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