@devicecloud.dev/dcd 0.0.5 → 0.0.6

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.
@@ -51,6 +51,7 @@ class Cloud extends core_1.Command {
51
51
  static flags = constants_1.flags;
52
52
  async run() {
53
53
  try {
54
+ await (0, methods_1.versionCheck)(this.config.version);
54
55
  const { args, flags, raw } = await this.parse(Cloud);
55
56
  const { 'android-api-level': androidApiLevel, 'android-device': androidDevice, apiKey, apiUrl, 'app-binary-id': appBinaryId, 'app-file': appFile, arm64, async, env, 'exclude-tags': excludeTags, flows, 'google-play': googlePlay, 'include-tags': includeTags, 'ios-device': iOSDevice, 'ios-version': iOSVersion, name, orientation, ...rest } = flags;
56
57
  if (arm64) {
@@ -177,6 +178,7 @@ class Cloud extends core_1.Command {
177
178
  continueOnFailure,
178
179
  orientation,
179
180
  raw,
181
+ version: this.config.version,
180
182
  }));
181
183
  if (androidApiLevel)
182
184
  testFormData.set('androidApiLevel', androidApiLevel.toString());
package/dist/methods.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import * as archiver from 'archiver';
3
3
  import { paths } from '../../api/schema.types';
4
+ export declare const versionCheck: (currentVersion: string) => Promise<void>;
4
5
  export declare const typeSafePost: <T extends keyof paths>(baseUrl: string, path: string, init?: {
5
6
  body?: FormData;
6
7
  headers?: HeadersInit;
package/dist/methods.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.verifyAppZip = exports.compressFilesFromRelativePath = exports.compressFolderToBlob = exports.compressDir = exports.toBuffer = exports.typeSafeGet = exports.typeSafePost = void 0;
3
+ exports.verifyAppZip = exports.compressFilesFromRelativePath = exports.compressFolderToBlob = exports.compressDir = exports.toBuffer = exports.typeSafeGet = exports.typeSafePost = exports.versionCheck = void 0;
4
+ const cli_ux_1 = require("@oclif/core/lib/cli-ux");
4
5
  const archiver = require("archiver");
5
6
  // import { writeFile } from 'node:fs/promises';
6
7
  const nodePath = require("node:path");
@@ -16,6 +17,20 @@ const PERMITTED_EXTENSIONS = new Set([
16
17
  'mp4',
17
18
  'js',
18
19
  ]);
20
+ const versionCheck = async (currentVersion) => {
21
+ const versionResponse = await fetch('https://registry.npmjs.org/@devicecloud.dev/dcd/latest');
22
+ const versionResponseJson = await versionResponse.json();
23
+ const latestVersion = versionResponseJson.version;
24
+ if (latestVersion !== currentVersion) {
25
+ (0, cli_ux_1.warn)(`
26
+ -------------------
27
+ A new version of the devicecloud.dev CLI is available: ${latestVersion}
28
+ Run 'npm install -g @devicecloud.dev/dcd' to update to the latest version
29
+ -------------------
30
+ `);
31
+ }
32
+ };
33
+ exports.versionCheck = versionCheck;
19
34
  const typeSafePost = async (baseUrl, path, init) => {
20
35
  const res = await fetch(baseUrl + path, { ...init, method: 'POST' });
21
36
  if (!res.ok) {
package/dist/plan.js CHANGED
@@ -12,15 +12,15 @@ async function plan(input, includeTags, excludeTags) {
12
12
  if (fs.lstatSync(input).isFile()) {
13
13
  const directory = path.dirname(input) + '/';
14
14
  const { config, testSteps } = (0, planMethods_1.readTestYamlFileAsJson)(input);
15
- const { allFiles, errors } = (0, planMethods_1.processDependencies)({
15
+ const { allErrors, allFiles } = (0, planMethods_1.processDependencies)({
16
16
  config,
17
17
  directory,
18
18
  input,
19
19
  testSteps,
20
20
  });
21
- if (errors.length > 0) {
21
+ if (allErrors.length > 0) {
22
22
  throw new Error('The following flow files are not present in the provided directory: \n' +
23
- errors.join('\n'));
23
+ allErrors.join('\n'));
24
24
  }
25
25
  return {
26
26
  flowsToRun: [input.split('/').pop() ?? input],
@@ -78,7 +78,7 @@ async function plan(input, includeTags, excludeTags) {
78
78
  for (const [filePath, testSteps] of Object.entries(testStepsPerFlowFile)) {
79
79
  if (!testSteps)
80
80
  break;
81
- const { allFiles: deps, errors: errs } = (0, planMethods_1.processDependencies)({
81
+ const { allErrors: errs, allFiles: deps } = (0, planMethods_1.processDependencies)({
82
82
  config: configPerFlowFile[path.relative(cleanPath, filePath)],
83
83
  directory: cleanPath,
84
84
  input: filePath,
@@ -22,7 +22,7 @@ interface IProcessDependencies {
22
22
  testSteps: Record<string, unknown>[];
23
23
  }
24
24
  export declare const processDependencies: ({ config, directory, input, testSteps, }: IProcessDependencies) => {
25
+ allErrors: string[];
25
26
  allFiles: string[];
26
- errors: string[];
27
27
  };
28
28
  export {};
@@ -108,8 +108,31 @@ const checkFile = (filePath, cleanPath) => {
108
108
  if (!filePath.startsWith(cleanPath))
109
109
  return `file outside the workspace`;
110
110
  };
111
- const processDependencies = ({ config, directory, input, testSteps, }) => {
111
+ const checkStepsArray = (steps, input, directory) => {
112
112
  let errors = [];
113
+ let files = [];
114
+ for (const command of steps) {
115
+ if (typeof command === 'string')
116
+ continue;
117
+ for (const [commandName, commandValue] of Object.entries(command)) {
118
+ if (commandsThatRequireFiles.has(commandName)) {
119
+ const { errors: newErrors, files: newFiles } = (0, exports.checkIfFilesExistInWorkspace)(commandName, commandValue, path.normalize(input), directory);
120
+ errors = [...errors, ...newErrors];
121
+ files = [...files, ...newFiles];
122
+ }
123
+ const nestedCommands = typeof commandValue === 'object' &&
124
+ commandValue.commands;
125
+ if (nestedCommands) {
126
+ const { errors: newErrors, files: newFiles } = checkStepsArray(nestedCommands, input, directory);
127
+ errors = [...errors, ...newErrors];
128
+ files = [...files, ...newFiles];
129
+ }
130
+ }
131
+ }
132
+ return { errors, files };
133
+ };
134
+ const processDependencies = ({ config, directory, input, testSteps, }) => {
135
+ let allErrors = [];
113
136
  let allFiles = [];
114
137
  const { onFlowComplete, onFlowStart } = config ?? {};
115
138
  const stepsArray = [testSteps];
@@ -117,19 +140,17 @@ const processDependencies = ({ config, directory, input, testSteps, }) => {
117
140
  stepsArray.push(onFlowStart);
118
141
  if (onFlowComplete)
119
142
  stepsArray.push(onFlowComplete);
120
- for (const steps of stepsArray) {
121
- for (const command of steps) {
122
- if (typeof command === 'string')
123
- continue;
124
- for (const [commandName, commandValue] of Object.entries(command)) {
125
- if (commandsThatRequireFiles.has(commandName)) {
126
- const { errors: newErrors, files } = (0, exports.checkIfFilesExistInWorkspace)(commandName, commandValue, path.normalize(input), directory);
127
- errors = [...errors, ...newErrors];
128
- allFiles = [...allFiles, ...files];
129
- }
130
- }
143
+ for (const [index, steps] of stepsArray.entries()) {
144
+ try {
145
+ const { errors, files } = checkStepsArray(steps, input, directory);
146
+ allErrors = [...allErrors, ...errors];
147
+ allFiles = [...allFiles, ...files];
148
+ }
149
+ catch {
150
+ const location = ['Test Steps', 'On Flow Start', 'On Flow Complete'][index];
151
+ throw new Error(`Error processing dependencies for file ${input} in the ${location} section. Expected an array of steps but received: ${JSON.stringify(steps)}`);
131
152
  }
132
153
  }
133
- return { allFiles, errors };
154
+ return { allErrors, allFiles };
134
155
  };
135
156
  exports.processDependencies = processDependencies;
@@ -220,5 +220,5 @@
220
220
  ]
221
221
  }
222
222
  },
223
- "version": "0.0.5"
223
+ "version": "0.0.6"
224
224
  }
package/package.json CHANGED
@@ -73,7 +73,7 @@
73
73
  "test": "mocha --forbid-only \"test/**/*.test.ts\"",
74
74
  "version": "oclif readme && git add README.md"
75
75
  },
76
- "version": "0.0.5",
76
+ "version": "0.0.6",
77
77
  "bugs": {
78
78
  "url": "https://discord.gg/gm3mJwcNw8"
79
79
  },