@xano/cli 0.0.8 → 0.0.10
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/commands/ephemeral/run/job/index.d.ts +2 -0
- package/dist/commands/ephemeral/run/job/index.js +41 -22
- package/dist/commands/ephemeral/run/service/index.d.ts +2 -0
- package/dist/commands/ephemeral/run/service/index.js +37 -18
- package/oclif.manifest.json +637 -637
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@ export default class EphemeralRunJob extends BaseCommand {
|
|
|
16
16
|
}),
|
|
17
17
|
file: Flags.string({
|
|
18
18
|
char: 'f',
|
|
19
|
-
description: 'Path to file containing XanoScript code',
|
|
19
|
+
description: 'Path or URL to file containing XanoScript code',
|
|
20
20
|
required: false,
|
|
21
21
|
exclusive: ['stdin'],
|
|
22
22
|
}),
|
|
@@ -43,7 +43,7 @@ export default class EphemeralRunJob extends BaseCommand {
|
|
|
43
43
|
}),
|
|
44
44
|
args: Flags.string({
|
|
45
45
|
char: 'a',
|
|
46
|
-
description: 'Path to JSON file containing input arguments',
|
|
46
|
+
description: 'Path or URL to JSON file containing input arguments',
|
|
47
47
|
required: false,
|
|
48
48
|
}),
|
|
49
49
|
};
|
|
@@ -113,26 +113,20 @@ Job executed successfully!
|
|
|
113
113
|
// Read XanoScript content
|
|
114
114
|
let xanoscript;
|
|
115
115
|
if (flags.file) {
|
|
116
|
-
//
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (flags.edit) {
|
|
120
|
-
fileToRead = await this.editFile(flags.file);
|
|
121
|
-
}
|
|
122
|
-
try {
|
|
116
|
+
// If edit flag is set and source is not a URL, copy to temp file and open in editor
|
|
117
|
+
if (flags.edit && !this.isUrl(flags.file)) {
|
|
118
|
+
const fileToRead = await this.editFile(flags.file);
|
|
123
119
|
xanoscript = fs.readFileSync(fileToRead, 'utf8');
|
|
124
|
-
// Clean up temp file
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// Ignore cleanup errors
|
|
131
|
-
}
|
|
120
|
+
// Clean up temp file
|
|
121
|
+
try {
|
|
122
|
+
fs.unlinkSync(fileToRead);
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
// Ignore cleanup errors
|
|
132
126
|
}
|
|
133
127
|
}
|
|
134
|
-
|
|
135
|
-
this.
|
|
128
|
+
else {
|
|
129
|
+
xanoscript = await this.fetchContent(flags.file);
|
|
136
130
|
}
|
|
137
131
|
}
|
|
138
132
|
else if (flags.stdin) {
|
|
@@ -151,15 +145,15 @@ Job executed successfully!
|
|
|
151
145
|
if (!xanoscript || xanoscript.trim().length === 0) {
|
|
152
146
|
this.error('XanoScript content is empty');
|
|
153
147
|
}
|
|
154
|
-
// Load args from JSON file if provided
|
|
148
|
+
// Load args from JSON file or URL if provided
|
|
155
149
|
let inputArgs;
|
|
156
150
|
if (flags.args) {
|
|
157
151
|
try {
|
|
158
|
-
const argsContent =
|
|
152
|
+
const argsContent = await this.fetchContent(flags.args);
|
|
159
153
|
inputArgs = JSON.parse(argsContent);
|
|
160
154
|
}
|
|
161
155
|
catch (error) {
|
|
162
|
-
this.error(`Failed to read or parse args
|
|
156
|
+
this.error(`Failed to read or parse args '${flags.args}': ${error}`);
|
|
163
157
|
}
|
|
164
158
|
}
|
|
165
159
|
// Construct the API URL
|
|
@@ -294,6 +288,31 @@ Job executed successfully!
|
|
|
294
288
|
process.stdin.resume();
|
|
295
289
|
});
|
|
296
290
|
}
|
|
291
|
+
isUrl(str) {
|
|
292
|
+
return str.startsWith('http://') || str.startsWith('https://');
|
|
293
|
+
}
|
|
294
|
+
async fetchContent(source) {
|
|
295
|
+
if (this.isUrl(source)) {
|
|
296
|
+
try {
|
|
297
|
+
const response = await fetch(source);
|
|
298
|
+
if (!response.ok) {
|
|
299
|
+
this.error(`Failed to fetch '${source}': ${response.status} ${response.statusText}`);
|
|
300
|
+
}
|
|
301
|
+
return await response.text();
|
|
302
|
+
}
|
|
303
|
+
catch (error) {
|
|
304
|
+
this.error(`Failed to fetch '${source}': ${error}`);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
try {
|
|
309
|
+
return fs.readFileSync(source, 'utf8');
|
|
310
|
+
}
|
|
311
|
+
catch (error) {
|
|
312
|
+
this.error(`Failed to read file '${source}': ${error}`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
297
316
|
loadCredentials() {
|
|
298
317
|
const configDir = path.join(os.homedir(), '.xano');
|
|
299
318
|
const credentialsPath = path.join(configDir, 'credentials.yaml');
|
|
@@ -16,7 +16,7 @@ export default class EphemeralRunService extends BaseCommand {
|
|
|
16
16
|
}),
|
|
17
17
|
file: Flags.string({
|
|
18
18
|
char: 'f',
|
|
19
|
-
description: 'Path to file containing XanoScript code',
|
|
19
|
+
description: 'Path or URL to file containing XanoScript code',
|
|
20
20
|
required: false,
|
|
21
21
|
exclusive: ['stdin'],
|
|
22
22
|
}),
|
|
@@ -103,26 +103,20 @@ Service created successfully!
|
|
|
103
103
|
// Read XanoScript content
|
|
104
104
|
let xanoscript;
|
|
105
105
|
if (flags.file) {
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (flags.edit) {
|
|
110
|
-
fileToRead = await this.editFile(flags.file);
|
|
111
|
-
}
|
|
112
|
-
try {
|
|
106
|
+
// If edit flag is set and source is not a URL, copy to temp file and open in editor
|
|
107
|
+
if (flags.edit && !this.isUrl(flags.file)) {
|
|
108
|
+
const fileToRead = await this.editFile(flags.file);
|
|
113
109
|
xanoscript = fs.readFileSync(fileToRead, 'utf8');
|
|
114
|
-
// Clean up temp file
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
// Ignore cleanup errors
|
|
121
|
-
}
|
|
110
|
+
// Clean up temp file
|
|
111
|
+
try {
|
|
112
|
+
fs.unlinkSync(fileToRead);
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
// Ignore cleanup errors
|
|
122
116
|
}
|
|
123
117
|
}
|
|
124
|
-
|
|
125
|
-
this.
|
|
118
|
+
else {
|
|
119
|
+
xanoscript = await this.fetchContent(flags.file);
|
|
126
120
|
}
|
|
127
121
|
}
|
|
128
122
|
else if (flags.stdin) {
|
|
@@ -266,6 +260,31 @@ Service created successfully!
|
|
|
266
260
|
process.stdin.resume();
|
|
267
261
|
});
|
|
268
262
|
}
|
|
263
|
+
isUrl(str) {
|
|
264
|
+
return str.startsWith('http://') || str.startsWith('https://');
|
|
265
|
+
}
|
|
266
|
+
async fetchContent(source) {
|
|
267
|
+
if (this.isUrl(source)) {
|
|
268
|
+
try {
|
|
269
|
+
const response = await fetch(source);
|
|
270
|
+
if (!response.ok) {
|
|
271
|
+
this.error(`Failed to fetch '${source}': ${response.status} ${response.statusText}`);
|
|
272
|
+
}
|
|
273
|
+
return await response.text();
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
this.error(`Failed to fetch '${source}': ${error}`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
try {
|
|
281
|
+
return fs.readFileSync(source, 'utf8');
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
this.error(`Failed to read file '${source}': ${error}`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
269
288
|
loadCredentials() {
|
|
270
289
|
const configDir = path.join(os.homedir(), '.xano');
|
|
271
290
|
const credentialsPath = path.join(configDir, 'credentials.yaml');
|