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

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.
@@ -13,8 +13,10 @@ export default class Cloud extends Command {
13
13
  appBinaryId: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
14
14
  appFile: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
15
15
  env: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
16
+ excludeTags: import("@oclif/core/lib/interfaces").OptionFlag<string[], import("@oclif/core/lib/interfaces").CustomOptions>;
16
17
  flows: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
17
18
  iOSVersion: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
19
+ includeTags: import("@oclif/core/lib/interfaces").OptionFlag<string[], import("@oclif/core/lib/interfaces").CustomOptions>;
18
20
  };
19
21
  run(): Promise<void>;
20
22
  }
@@ -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({
@@ -96,13 +108,18 @@ class Cloud extends core_1.Command {
96
108
  description: 'App binary to run your Flows against',
97
109
  }),
98
110
  env: core_1.Flags.file({
99
- aliases: ['env'],
100
111
  char: 'e',
101
112
  description: 'One or more environment variables to inject into your Flows',
102
113
  multiple: true,
103
114
  }),
115
+ excludeTags: core_1.Flags.string({
116
+ aliases: ['exclude-tags'],
117
+ default: [],
118
+ description: 'Flows which have these tags will be excluded from the run',
119
+ multiple: true,
120
+ parse: (input) => input.split(','),
121
+ }),
104
122
  flows: core_1.Flags.string({
105
- aliases: ['flows'],
106
123
  description: 'The path to the flow file or folder containing your Flows',
107
124
  }),
108
125
  iOSVersion: core_1.Flags.string({
@@ -110,10 +127,17 @@ class Cloud extends core_1.Command {
110
127
  description: 'iOS version to run your flow against',
111
128
  options: ['16.4', '17.2'],
112
129
  }),
130
+ includeTags: core_1.Flags.string({
131
+ aliases: ['include-tags'],
132
+ default: [],
133
+ description: 'Only Flows which have these tags will be included in the run',
134
+ multiple: true,
135
+ parse: (input) => input.split(','),
136
+ }),
113
137
  };
114
138
  async run() {
115
139
  const { args, flags } = await this.parse(Cloud);
116
- const { apiKey, apiUrl, appBinaryId, appFile, env, flows, ...rest } = flags;
140
+ const { apiKey, apiUrl, appBinaryId, appFile, env, excludeTags, flows, includeTags, ...rest } = flags;
117
141
  console.log({ args });
118
142
  const { firstFile, secondFile } = args;
119
143
  let finalBinaryId = appBinaryId;
@@ -135,6 +159,9 @@ class Cloud extends core_1.Command {
135
159
  }
136
160
  this.log(`you want to run the flow(s) ${flowFile} against the app ${finalAppFile} with the following flags: ${JSON.stringify(flags)}`);
137
161
  }
162
+ if (!flowFile) {
163
+ throw new Error('You must provide a flow file');
164
+ }
138
165
  if (!finalBinaryId) {
139
166
  const binaryFormData = new FormData();
140
167
  const binaryBlob = new Blob([await (0, promises_1.readFile)(finalAppFile)], {
@@ -155,9 +182,9 @@ class Cloud extends core_1.Command {
155
182
  }
156
183
  const testFileNames = [];
157
184
  let flowFileDirectory = flowFile;
158
- if (flowFile?.endsWith('/')) {
185
+ if (!flowFile?.endsWith('.yaml') && !flowFile?.endsWith('.yml')) {
159
186
  try {
160
- const executionPlan = await (0, plan_1.plan)(flowFile, [], []);
187
+ const executionPlan = await (0, plan_1.plan)(flowFile, includeTags.flat(), excludeTags.flat());
161
188
  for (const file of executionPlan.flowsToRun) {
162
189
  testFileNames.push(file);
163
190
  }
@@ -183,7 +210,9 @@ class Cloud extends core_1.Command {
183
210
  acc[key] = value;
184
211
  return acc;
185
212
  }, {});
186
- const buffer = await compress(flowFileDirectory);
213
+ const buffer = flowFileDirectory?.length
214
+ ? await compressDir(flowFileDirectory)
215
+ : await compressFile(flowFile);
187
216
  const blob = new Blob([buffer], {
188
217
  type: mimeTypeLookupByExtension.zip,
189
218
  });
package/dist/plan.js CHANGED
@@ -39,7 +39,7 @@ const readConfigFromYamlFileAsJson = (filePath) => {
39
39
  if (yamlText.includes('\n---\n')) {
40
40
  const yamlTexts = yamlText.split('\n---\n');
41
41
  const config = yaml.load(yamlTexts[0]);
42
- if (Object.keys(config).filter((key) => key === 'appId').length > 1) {
42
+ if (Object.keys(config).length > 0) {
43
43
  return config;
44
44
  }
45
45
  }
@@ -77,9 +77,6 @@
77
77
  "type": "option"
78
78
  },
79
79
  "env": {
80
- "aliases": [
81
- "env"
82
- ],
83
80
  "char": "e",
84
81
  "description": "One or more environment variables to inject into your Flows",
85
82
  "name": "env",
@@ -87,10 +84,18 @@
87
84
  "multiple": true,
88
85
  "type": "option"
89
86
  },
90
- "flows": {
87
+ "excludeTags": {
91
88
  "aliases": [
92
- "flows"
89
+ "exclude-tags"
93
90
  ],
91
+ "description": "Flows which have these tags will be excluded from the run",
92
+ "name": "excludeTags",
93
+ "default": [],
94
+ "hasDynamicHelp": false,
95
+ "multiple": true,
96
+ "type": "option"
97
+ },
98
+ "flows": {
94
99
  "description": "The path to the flow file or folder containing your Flows",
95
100
  "name": "flows",
96
101
  "hasDynamicHelp": false,
@@ -110,6 +115,17 @@
110
115
  "17.2"
111
116
  ],
112
117
  "type": "option"
118
+ },
119
+ "includeTags": {
120
+ "aliases": [
121
+ "include-tags"
122
+ ],
123
+ "description": "Only Flows which have these tags will be included in the run",
124
+ "name": "includeTags",
125
+ "default": [],
126
+ "hasDynamicHelp": false,
127
+ "multiple": true,
128
+ "type": "option"
113
129
  }
114
130
  },
115
131
  "hasDynamicHelp": false,
@@ -128,5 +144,5 @@
128
144
  ]
129
145
  }
130
146
  },
131
- "version": "0.0.1-alpha.3"
147
+ "version": "0.0.1-alpha.5"
132
148
  }
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.5",
78
78
  "bugs": {
79
79
  "url": "https://discord.gg/GzZBHcUJ"
80
80
  },