@todesktop/shared 7.76.0 → 7.79.0

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.
@@ -143,6 +143,10 @@ export interface DesktopifyAppWindow {
143
143
  }
144
144
  export interface DesktopifyApp2 {
145
145
  id: string;
146
+ /**
147
+ * Last ToDesktop Builder version that was used to update the app
148
+ */
149
+ lastUsedBuilderVersion: string;
146
150
  /**
147
151
  * The name of the app
148
152
  */
@@ -1,5 +1,6 @@
1
1
  import * as yup from "yup";
2
2
  export declare const appTitleValidation: yup.StringSchema;
3
+ export declare const forceVersionValidation: yup.StringSchema;
3
4
  export declare const iconValidation: yup.StringSchema;
4
5
  export declare const urlValidation: yup.StringSchema;
5
6
  export declare const urlValidationForm: yup.ObjectSchema<yup.Shape<object, {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const yup = require("yup");
4
+ const semver = require("semver");
4
5
  const isRegex = require("is-regex");
5
6
  exports.appTitleValidation = yup
6
7
  .string()
@@ -9,6 +10,28 @@ exports.appTitleValidation = yup
9
10
  .matches(/^[\w\-\s]+$/, "App title may contain letters, numbers, spaces and dashes only")
10
11
  .matches(/^[^\s]+(\s+[^\s]+)*$/, "App title may not begin or end with space")
11
12
  .required();
13
+ function isNumeric(str) {
14
+ if (typeof str != "string")
15
+ return false;
16
+ return !isNaN(str) && !isNaN(parseFloat(str));
17
+ }
18
+ function isNumericSemver(value) {
19
+ // check if valid semver
20
+ if (!semver.valid(value))
21
+ return false;
22
+ // ensure that all values are numbers
23
+ if (!value.split(".").every((num) => isNumeric(num)))
24
+ return false;
25
+ return true;
26
+ }
27
+ exports.forceVersionValidation = yup
28
+ .string()
29
+ .label("App version")
30
+ .required()
31
+ .when("$currentVersion", (currentVersion, schema) => schema.test("semantic-version", "App version must follow a numeric SemVer versioning scheme (e.g. 1.0.0) and be greater than prior version.", (forceVersion) => {
32
+ return (isNumericSemver(forceVersion) &&
33
+ semver.gt(forceVersion, currentVersion));
34
+ }));
12
35
  exports.iconValidation = yup
13
36
  .string()
14
37
  .label("Icon")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@todesktop/shared",
3
- "version": "7.76.0",
3
+ "version": "7.79.0",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -19,9 +19,11 @@
19
19
  "@types/node": "^16.4.12",
20
20
  "@types/yup": "^0.26.9",
21
21
  "is-regex": "^1.0.4",
22
+ "semver": "^7.3.5",
22
23
  "yup": "^0.26.10"
23
24
  },
24
25
  "devDependencies": {
26
+ "@types/semver": "^7.3.9",
25
27
  "app-builder-lib": "^22.10.4",
26
28
  "tslint": "^5.12.1",
27
29
  "tslint-config-prettier": "1.18.0",
@@ -250,6 +250,10 @@ export interface DesktopifyAppWindow {
250
250
 
251
251
  export interface DesktopifyApp2 {
252
252
  id: string;
253
+ /**
254
+ * Last ToDesktop Builder version that was used to update the app
255
+ */
256
+ lastUsedBuilderVersion: string;
253
257
  /**
254
258
  * The name of the app
255
259
  */
@@ -1,4 +1,5 @@
1
1
  import * as yup from "yup";
2
+ import * as semver from "semver";
2
3
  import * as isRegex from "is-regex";
3
4
  export const appTitleValidation = yup
4
5
  .string()
@@ -11,6 +12,38 @@ export const appTitleValidation = yup
11
12
  .matches(/^[^\s]+(\s+[^\s]+)*$/, "App title may not begin or end with space")
12
13
  .required();
13
14
 
15
+ function isNumeric(str: string) {
16
+ if (typeof str != "string") return false;
17
+ return !isNaN(str as any) && !isNaN(parseFloat(str));
18
+ }
19
+
20
+ function isNumericSemver(value: string) {
21
+ // check if valid semver
22
+ if (!semver.valid(value)) return false;
23
+
24
+ // ensure that all values are numbers
25
+ if (!value.split(".").every((num) => isNumeric(num))) return false;
26
+
27
+ return true;
28
+ }
29
+
30
+ export const forceVersionValidation = yup
31
+ .string()
32
+ .label("App version")
33
+ .required()
34
+ .when("$currentVersion", (currentVersion, schema) =>
35
+ schema.test(
36
+ "semantic-version",
37
+ "App version must follow a numeric SemVer versioning scheme (e.g. 1.0.0) and be greater than prior version.",
38
+ (forceVersion: string) => {
39
+ return (
40
+ isNumericSemver(forceVersion) &&
41
+ semver.gt(forceVersion, currentVersion)
42
+ );
43
+ }
44
+ )
45
+ );
46
+
14
47
  export const iconValidation = yup
15
48
  .string()
16
49
  .label("Icon")