@devicecloud.dev/dcd 0.0.1-alpha.3 → 0.0.1-alpha.4

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.
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable complexity */
3
4
  const core_1 = require("@oclif/core");
4
5
  const archiver = require("archiver");
5
6
  const promises_1 = require("node:fs/promises");
@@ -41,7 +42,7 @@ const toBuffer = async (archive) => {
41
42
  // once done, concatenate chunks
42
43
  return Buffer.concat(chunks);
43
44
  };
44
- const compress = async (sourceDir) => {
45
+ const compressDir = async (sourceDir) => {
45
46
  // const output = createWriteStream(zipTargetPath);
46
47
  const archive = archiver('zip', {
47
48
  zlib: { level: 9 },
@@ -49,7 +50,6 @@ const compress = async (sourceDir) => {
49
50
  archive.on('error', (err) => {
50
51
  throw err;
51
52
  });
52
- // archive.pipe(output);
53
53
  archive.directory(sourceDir, false, (data) => {
54
54
  if (PERMITTED_EXTENSIONS.has(data.name.split('.').pop())) {
55
55
  return data;
@@ -59,6 +59,18 @@ const compress = async (sourceDir) => {
59
59
  const buffer = await toBuffer(archive);
60
60
  return buffer;
61
61
  };
62
+ const compressFile = async (sourceFile) => {
63
+ const archive = archiver('zip', {
64
+ zlib: { level: 9 },
65
+ });
66
+ archive.on('error', (err) => {
67
+ throw err;
68
+ });
69
+ archive.file(sourceFile, { name: sourceFile });
70
+ const buffer = await toBuffer(archive);
71
+ // await writeFile('./my-zip.zip', buffer);
72
+ return buffer;
73
+ };
62
74
  class Cloud extends core_1.Command {
63
75
  static args = {
64
76
  firstFile: core_1.Args.string({
@@ -135,6 +147,9 @@ class Cloud extends core_1.Command {
135
147
  }
136
148
  this.log(`you want to run the flow(s) ${flowFile} against the app ${finalAppFile} with the following flags: ${JSON.stringify(flags)}`);
137
149
  }
150
+ if (!flowFile) {
151
+ throw new Error('You must provide a flow file');
152
+ }
138
153
  if (!finalBinaryId) {
139
154
  const binaryFormData = new FormData();
140
155
  const binaryBlob = new Blob([await (0, promises_1.readFile)(finalAppFile)], {
@@ -155,7 +170,7 @@ class Cloud extends core_1.Command {
155
170
  }
156
171
  const testFileNames = [];
157
172
  let flowFileDirectory = flowFile;
158
- if (flowFile?.endsWith('/')) {
173
+ if (!flowFile?.endsWith('.yaml') && !flowFile?.endsWith('.yml')) {
159
174
  try {
160
175
  const executionPlan = await (0, plan_1.plan)(flowFile, [], []);
161
176
  for (const file of executionPlan.flowsToRun) {
@@ -183,7 +198,9 @@ class Cloud extends core_1.Command {
183
198
  acc[key] = value;
184
199
  return acc;
185
200
  }, {});
186
- const buffer = await compress(flowFileDirectory);
201
+ const buffer = flowFileDirectory?.length
202
+ ? await compressDir(flowFileDirectory)
203
+ : await compressFile(flowFile);
187
204
  const blob = new Blob([buffer], {
188
205
  type: mimeTypeLookupByExtension.zip,
189
206
  });
@@ -128,5 +128,5 @@
128
128
  ]
129
129
  }
130
130
  },
131
- "version": "0.0.1-alpha.3"
131
+ "version": "0.0.1-alpha.4"
132
132
  }
package/package.json CHANGED
@@ -74,7 +74,7 @@
74
74
  "test": "mocha --forbid-only \"test/**/*.test.ts\"",
75
75
  "version": "oclif readme && git add README.md"
76
76
  },
77
- "version": "0.0.1-alpha.3",
77
+ "version": "0.0.1-alpha.4",
78
78
  "bugs": {
79
79
  "url": "https://discord.gg/GzZBHcUJ"
80
80
  },