esoui-publish 2.1.13 → 2.2.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.
package/README.md CHANGED
@@ -1,34 +1,34 @@
1
- # esoui-publish
2
- A simple node utility that will publish addons to [ESOUI](https://www.esoui.com/community.php).
3
-
4
- ## Setup
5
- ### Install
6
- - Generate an esoui access token. They can be generated [on ESOUI](https://www.esoui.com/downloads/filecpl.php?action=apitokens). Tokens are like passwords. Make sure to keep them secure.
7
- `npm install -g esoui-publish`
8
- ### Prepare
9
- - Recommend setting the `ESOUI_TOKEN` environment variable so you do not have to store it in code or use it on the command line.
10
- - The addon description and changelog can be read from files. If no files are provided the main add on page will not be affected.
11
- - Any missing arguments will result in no change to that attribute.
12
- - The `testDeploy` argument will test your upload against https://api.esoui.com/addons/updatetest which will verify your upload will be accepted.
13
-
14
- ## Run
15
- ### Command Line
16
- `esoui-publish --id=2272 --description='esoui-description.txt' --changelog='esoui-changelog.txt' --compatibility='5.2.5' --updateFile=esoui-publish-1514.zip --testDeploy=true`
17
-
18
- ### JavaScript
19
- ```javascript
20
- const EsouiPublish = require('esoui-publish').EsouiPublish;
21
- const params = {
22
- id: 2272,
23
- version: '1.0.0',
24
- description: 'esoui-description.txt',
25
- changelog: 'esoui-changelog.txt',
26
- compatibility: '5.2.5',
27
- updateFile: 'esoui-publish.zip',
28
- testDeploy: true // Remove or set to false to publish for real.
29
- };
30
-
31
- new EsouiPublish(process.env.ESOUI_TOKEN, params).createUpdatePackageAndUpdate()
32
- .then(response => console.log(JSON.stringify(response, null, 2)))
33
- .catch(error => console.log(error));
1
+ # esoui-publish
2
+ A simple node utility that will publish addons to [ESOUI](https://www.esoui.com/community.php).
3
+
4
+ ## Setup
5
+ ### Install
6
+ - Generate an esoui access token. They can be generated [on ESOUI](https://www.esoui.com/downloads/filecpl.php?action=apitokens). Tokens are like passwords. Make sure to keep them secure.
7
+ `npm install -g esoui-publish`
8
+ ### Prepare
9
+ - Recommend setting the `ESOUI_TOKEN` environment variable so you do not have to store it in code or use it on the command line.
10
+ - The addon description and changelog can be read from files. If no files are provided the main add on page will not be affected.
11
+ - Any missing arguments will result in no change to that attribute.
12
+ - The `testDeploy` argument will test your upload against https://api.esoui.com/addons/updatetest which will verify your upload will be accepted.
13
+
14
+ ## Run
15
+ ### Command Line
16
+ `esoui-publish --id=2272 --description='esoui-description.txt' --changelog='esoui-changelog.txt' --compatibility='5.2.5' --updateFile=esoui-publish-1514.zip --testDeploy=true`
17
+
18
+ ### JavaScript
19
+ ```javascript
20
+ const EsouiPublish = require('esoui-publish').EsouiPublish;
21
+ const params = {
22
+ id: 2272,
23
+ version: '1.0.0',
24
+ description: 'esoui-description.txt',
25
+ changelog: 'esoui-changelog.txt',
26
+ compatibility: '5.2.5',
27
+ updateFile: 'esoui-publish.zip',
28
+ testDeploy: true // Remove or set to false to publish for real.
29
+ };
30
+
31
+ new EsouiPublish(process.env.ESOUI_TOKEN, params).createUpdatePackageAndUpdate()
32
+ .then(response => console.log(JSON.stringify(response, null, 2)))
33
+ .catch(error => console.log(error));
34
34
  ```
package/dist/bin.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ #!/usr/bin/env node
2
+ export {};
3
3
  //# sourceMappingURL=bin.d.ts.map
package/dist/bin.js CHANGED
@@ -1,28 +1,31 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- var index_1 = require("./index");
8
- var yargs_1 = __importDefault(require("yargs"));
9
- var argv = yargs_1.default.options({
10
- token: { type: 'string', description: "Recommend setting `ESOUI_TOKEN` environment variable to avoid exposing token via logs. Otherwise this parameter is required." },
11
- id: { type: 'number', demandOption: true, description: "ID of the addon to update" },
12
- version: { type: 'string', description: "Version of the new version" },
13
- description: { type: 'string', description: "Name of the file that contains the addon description. (aka what is shown on the main page of your addon)" },
14
- changelog: { type: 'string', description: "Name of the file that contains the changelog" },
15
- compatibility: { type: 'string', description: "Game version your addon supports. (i.e. `5.2.5`)" },
16
- updatefile: { type: 'string', description: "Name of the file that contains the zip package to upload to esoui" },
17
- testDeploy: { type: 'boolean', description: "Set to true to validate upload parameters without updating the actual add on" }
18
- }).argv;
19
- var token = argv.token || process.env.ESOUI_TOKEN;
20
- if (token) {
21
- index_1.EsouiPublish.publish(token, argv.id, argv.version, argv.description, argv.changelog, argv.compatibility, argv.updatefile, argv.testDeploy)
22
- .then(function (response) { return console.log(JSON.stringify(response, null, 2)); })
23
- .catch(console.error);
24
- }
25
- else {
26
- throw new Error('No token found. Either provide via `--token=<you\'re token>` or set the ESOUI_TOKEN environment variable');
27
- }
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ var index_1 = require("./index");
8
+ var yargs_1 = __importDefault(require("yargs"));
9
+ var argv = yargs_1.default.options({
10
+ token: { type: 'string', description: "Recommend setting `ESOUI_TOKEN` environment variable to avoid exposing token via logs. Otherwise this parameter is required." },
11
+ id: { type: 'number', demandOption: true, description: "ID of the addon to update" },
12
+ version: { type: 'string', description: "Version of the new version" },
13
+ description: { type: 'string', description: "Name of the file that contains the addon description. (aka what is shown on the main page of your addon)" },
14
+ changelog: { type: 'string', description: "Name of the file that contains the changelog" },
15
+ compatibility: { type: 'string', description: "Game version your addon supports. (i.e. `5.2.5`)" },
16
+ updatefile: { type: 'string', description: "Name of the file that contains the zip package to upload to esoui" },
17
+ testDeploy: { type: 'boolean', description: "Set to true to validate upload parameters without updating the actual add on" }
18
+ }).argv;
19
+ var token = argv.token || process.env.ESOUI_TOKEN;
20
+ if (!argv.version) {
21
+ throw new Error('Version is required. Please provide via `--version=<version>`');
22
+ }
23
+ if (token) {
24
+ index_1.EsouiPublish.publish(token, argv.id, argv.version, argv.description, argv.changelog, argv.compatibility, argv.updatefile, argv.testDeploy)
25
+ .then(function (response) { return console.log(JSON.stringify(response, null, 2)); })
26
+ .catch(console.error);
27
+ }
28
+ else {
29
+ throw new Error('No token found. Either provide via `--token=<you\'re token>` or set the ESOUI_TOKEN environment variable');
30
+ }
28
31
  //# sourceMappingURL=bin.js.map
package/dist/bin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";;;;;;AACA,iCAAuC;AAEvC,gDAA0B;AAC1B,IAAM,IAAI,GAAG,eAAK,CAAC,OAAO,CAAC;IACzB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,8HAA8H,EAAE;IACtK,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,2BAA2B,EAAE;IACpF,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,4BAA4B,EAAE;IACtE,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,0GAA0G,EAAE;IACxJ,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,8CAA8C,EAAE;IAC1F,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kDAAkD,EAAE;IAClG,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,mEAAmE,EAAE;IAChH,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,8EAA8E,EAAE;CAC7H,CAAC,CAAC,IAAI,CAAC;AAER,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;AACpD,IAAI,KAAK,EAAE;IACT,oBAAY,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC;SACvI,IAAI,CAAC,UAAA,QAAQ,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAA9C,CAA8C,CAAC;SAChE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;CACzB;KAAM;IACL,MAAM,IAAI,KAAK,CAAC,0GAA0G,CAAC,CAAC;CAC7H"}
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";;;;;;AACA,iCAAuC;AAEvC,gDAA0B;AAC1B,IAAM,IAAI,GAAG,eAAK,CAAC,OAAO,CAAC;IACzB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,8HAA8H,EAAE;IACtK,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,2BAA2B,EAAE;IACpF,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,4BAA4B,EAAE;IACtE,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,0GAA0G,EAAE;IACxJ,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,8CAA8C,EAAE;IAC1F,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kDAAkD,EAAE;IAClG,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,mEAAmE,EAAE;IAChH,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,8EAA8E,EAAE;CAC7H,CAAC,CAAC,IAAI,CAAC;AAER,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;AACpD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAC;IAChB,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;CAClF;AAED,IAAI,KAAK,EAAE;IACT,oBAAY,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC;SACvI,IAAI,CAAC,UAAA,QAAQ,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAA9C,CAA8C,CAAC;SAChE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;CACzB;KAAM;IACL,MAAM,IAAI,KAAK,CAAC,0GAA0G,CAAC,CAAC;CAC7H"}
package/dist/index.d.ts CHANGED
@@ -1,45 +1,45 @@
1
- /// <reference types="node" />
2
- import fs from 'fs';
3
- export interface IEsouiPublishBase {
4
- id: number;
5
- version?: string;
6
- description?: string;
7
- changelog?: string;
8
- compatibility?: string;
9
- }
10
- export interface IEsouiUpdateParams extends IEsouiPublishBase {
11
- updatefile?: string;
12
- testDeploy?: boolean;
13
- }
14
- export interface IEsouiUpdatePackage extends IEsouiPublishBase {
15
- updatefile?: fs.ReadStream;
16
- }
17
- export interface IEsouiUpdateResult {
18
- responseStatusCode: number;
19
- responseBody: any;
20
- params: IEsouiUpdateParams;
21
- }
22
- export declare class EsouiPublish {
23
- private readonly token;
24
- private readonly params;
25
- constructor(token: string, params: IEsouiUpdateParams);
26
- /**
27
- * Convenience method that generates the update package and performs the update to esoui.
28
- **/
29
- createUpdatePackageAndUpdate(): Promise<IEsouiUpdateResult>;
30
- /**
31
- * Generates an 'update package' that contains the info needed to update to esoui.com
32
- */
33
- createEsouiUpdatePackage(): Promise<IEsouiUpdatePackage>;
34
- /**
35
- * Performs update to esoui.
36
- *
37
- * @param updatePackage
38
- *
39
- */
40
- updateEsoui(updatePackage: IEsouiUpdatePackage): Promise<IEsouiUpdateResult>;
41
- static publish(token: string, id: number, version?: string, description?: string, changelog?: string, compatibility?: string, updateFile?: string, test?: boolean): Promise<IEsouiUpdateResult>;
42
- static publishFromJson(jsonFile: string): Promise<IEsouiUpdateResult>;
43
- private static readFile;
44
- }
1
+ /// <reference types="node" />
2
+ import fs from 'fs';
3
+ export interface IEsouiPublishBase {
4
+ id: number;
5
+ version?: string;
6
+ description?: string;
7
+ changelog?: string;
8
+ compatibility?: string;
9
+ }
10
+ export interface IEsouiUpdateParams extends IEsouiPublishBase {
11
+ updatefile?: string;
12
+ testDeploy?: boolean;
13
+ }
14
+ export interface IEsouiUpdatePackage extends IEsouiPublishBase {
15
+ updatefile?: fs.ReadStream;
16
+ }
17
+ export interface IEsouiUpdateResult {
18
+ responseStatusCode: number;
19
+ responseBody: any;
20
+ params: IEsouiUpdateParams;
21
+ }
22
+ export declare class EsouiPublish {
23
+ private readonly token;
24
+ private readonly params;
25
+ constructor(token: string, params: IEsouiUpdateParams);
26
+ /**
27
+ * Convenience method that generates the update package and performs the update to esoui.
28
+ **/
29
+ createUpdatePackageAndUpdate(): Promise<IEsouiUpdateResult>;
30
+ /**
31
+ * Generates an 'update package' that contains the info needed to update to esoui.com
32
+ */
33
+ createEsouiUpdatePackage(): Promise<IEsouiUpdatePackage>;
34
+ /**
35
+ * Performs update to esoui.
36
+ *
37
+ * @param updatePackage
38
+ *
39
+ */
40
+ updateEsoui(updatePackage: IEsouiUpdatePackage): Promise<IEsouiUpdateResult>;
41
+ static publish(token: string, id: number, version?: string, description?: string, changelog?: string, compatibility?: string, updateFile?: string, test?: boolean): Promise<IEsouiUpdateResult>;
42
+ static publishFromJson(jsonFile: string): Promise<IEsouiUpdateResult>;
43
+ private static readFile;
44
+ }
45
45
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,220 +1,220 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- var fs_1 = __importDefault(require("fs"));
43
- var request_1 = __importDefault(require("request"));
44
- var EsouiPublish = /** @class */ (function () {
45
- function EsouiPublish(token, params) {
46
- this.token = token;
47
- this.params = params;
48
- }
49
- /**
50
- * Convenience method that generates the update package and performs the update to esoui.
51
- **/
52
- EsouiPublish.prototype.createUpdatePackageAndUpdate = function () {
53
- return __awaiter(this, void 0, void 0, function () {
54
- var _this = this;
55
- return __generator(this, function (_a) {
56
- return [2 /*return*/, this.createEsouiUpdatePackage()
57
- .then(function (updatePackage) { return _this.updateEsoui(updatePackage); })];
58
- });
59
- });
60
- };
61
- /**
62
- * Generates an 'update package' that contains the info needed to update to esoui.com
63
- */
64
- EsouiPublish.prototype.createEsouiUpdatePackage = function () {
65
- return __awaiter(this, void 0, void 0, function () {
66
- var updatePackage, _a, _b;
67
- return __generator(this, function (_c) {
68
- switch (_c.label) {
69
- case 0:
70
- updatePackage = {
71
- id: this.params.id
72
- };
73
- if (this.params.version) {
74
- updatePackage.version = this.params.version;
75
- }
76
- if (!this.params.description) return [3 /*break*/, 2];
77
- _a = updatePackage;
78
- return [4 /*yield*/, EsouiPublish.readFile(this.params.description)];
79
- case 1:
80
- _a.description = _c.sent();
81
- _c.label = 2;
82
- case 2:
83
- if (!this.params.changelog) return [3 /*break*/, 4];
84
- _b = updatePackage;
85
- return [4 /*yield*/, EsouiPublish.readFile(this.params.changelog)];
86
- case 3:
87
- _b.changelog = _c.sent();
88
- _c.label = 4;
89
- case 4:
90
- if (this.params.compatibility) {
91
- updatePackage.compatibility = this.params.compatibility;
92
- }
93
- if (this.params.updatefile) {
94
- updatePackage.updatefile = fs_1.default.createReadStream(this.params.updatefile);
95
- }
96
- return [2 /*return*/, updatePackage];
97
- }
98
- });
99
- });
100
- };
101
- /**
102
- * Performs update to esoui.
103
- *
104
- * @param updatePackage
105
- *
106
- */
107
- EsouiPublish.prototype.updateEsoui = function (updatePackage) {
108
- return __awaiter(this, void 0, void 0, function () {
109
- var endpoint;
110
- var _this = this;
111
- return __generator(this, function (_a) {
112
- endpoint = "https://api.esoui.com/addons/update" + (this.params.testDeploy ? 'test' : '');
113
- if (this.params.testDeploy) {
114
- console.warn('****TEST DEPLOYMENT****');
115
- }
116
- console.log("Publishing to " + endpoint);
117
- return [2 /*return*/, new Promise(function (resolve, reject) {
118
- var handleResponse = function (error, httpResponse, body) {
119
- if (error) {
120
- return reject(error);
121
- }
122
- if (httpResponse.statusCode !== 202) {
123
- if (httpResponse.statusCode === 403) {
124
- return reject('Unauthorized. Ensure correct token is set in `ESOUI_TOKEN` environment variable or provided via command line (--token=<you\'re token>)');
125
- }
126
- else {
127
- return reject(body);
128
- }
129
- }
130
- resolve({ responseStatusCode: httpResponse.statusCode, responseBody: JSON.parse(body), params: _this.params });
131
- };
132
- request_1.default.post({
133
- headers: {
134
- 'x-api-token': _this.token
135
- },
136
- url: endpoint,
137
- formData: updatePackage
138
- }, handleResponse);
139
- })];
140
- });
141
- });
142
- };
143
- EsouiPublish.publish = function (token, id, version, description, changelog, compatibility, updateFile, test) {
144
- return __awaiter(this, void 0, void 0, function () {
145
- var params;
146
- return __generator(this, function (_a) {
147
- params = {
148
- id: id,
149
- version: version,
150
- description: description,
151
- changelog: changelog,
152
- compatibility: compatibility,
153
- updatefile: updateFile,
154
- testDeploy: test
155
- };
156
- return [2 /*return*/, new EsouiPublish(token, params).createUpdatePackageAndUpdate()];
157
- });
158
- });
159
- };
160
- EsouiPublish.publishFromJson = function (jsonFile) {
161
- return __awaiter(this, void 0, void 0, function () {
162
- var _this = this;
163
- return __generator(this, function (_a) {
164
- return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
165
- var json, _a, _b, error_1, token, params;
166
- return __generator(this, function (_c) {
167
- switch (_c.label) {
168
- case 0:
169
- _c.trys.push([0, 2, , 3]);
170
- _b = (_a = JSON).parse;
171
- return [4 /*yield*/, EsouiPublish.readFile(jsonFile)];
172
- case 1:
173
- json = _b.apply(_a, [_c.sent()]);
174
- return [3 /*break*/, 3];
175
- case 2:
176
- error_1 = _c.sent();
177
- return [2 /*return*/, reject(error_1)];
178
- case 3:
179
- if (json && json.id) {
180
- token = json.token || process.env.ESOUI_TOKEN;
181
- if (!token) {
182
- return [2 /*return*/, reject('`token` not set in the JSON file or the ESOUI_TOKEN environment variable')];
183
- }
184
- params = { id: json.id };
185
- json.version ? params.version = json.version : undefined;
186
- json.description ? params.description = json.description : undefined;
187
- json.changelog ? params.changelog = json.changelog : undefined;
188
- json.compatibility ? params.compatibility = json.compatibility : undefined;
189
- json.updateFile ? params.updatefile = json.updateFile : undefined;
190
- json.test ? params.testDeploy = json.test : undefined;
191
- resolve(new EsouiPublish(token, params).createUpdatePackageAndUpdate());
192
- }
193
- else {
194
- return [2 /*return*/, reject('Missing `id`')];
195
- }
196
- return [2 /*return*/];
197
- }
198
- });
199
- }); })];
200
- });
201
- });
202
- };
203
- EsouiPublish.readFile = function (file) {
204
- return __awaiter(this, void 0, void 0, function () {
205
- return __generator(this, function (_a) {
206
- return [2 /*return*/, new Promise(function (resolve, reject) { return fs_1.default.readFile(file, 'utf8', function (error, data) {
207
- if (error) {
208
- reject(error);
209
- }
210
- else {
211
- resolve(data);
212
- }
213
- }); })];
214
- });
215
- });
216
- };
217
- return EsouiPublish;
218
- }());
219
- exports.EsouiPublish = EsouiPublish;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var fs_1 = __importDefault(require("fs"));
43
+ var request_1 = __importDefault(require("request"));
44
+ var EsouiPublish = /** @class */ (function () {
45
+ function EsouiPublish(token, params) {
46
+ this.token = token;
47
+ this.params = params;
48
+ }
49
+ /**
50
+ * Convenience method that generates the update package and performs the update to esoui.
51
+ **/
52
+ EsouiPublish.prototype.createUpdatePackageAndUpdate = function () {
53
+ return __awaiter(this, void 0, void 0, function () {
54
+ var _this = this;
55
+ return __generator(this, function (_a) {
56
+ return [2 /*return*/, this.createEsouiUpdatePackage()
57
+ .then(function (updatePackage) { return _this.updateEsoui(updatePackage); })];
58
+ });
59
+ });
60
+ };
61
+ /**
62
+ * Generates an 'update package' that contains the info needed to update to esoui.com
63
+ */
64
+ EsouiPublish.prototype.createEsouiUpdatePackage = function () {
65
+ return __awaiter(this, void 0, void 0, function () {
66
+ var updatePackage, _a, _b;
67
+ return __generator(this, function (_c) {
68
+ switch (_c.label) {
69
+ case 0:
70
+ updatePackage = {
71
+ id: this.params.id
72
+ };
73
+ if (this.params.version) {
74
+ updatePackage.version = this.params.version;
75
+ }
76
+ if (!this.params.description) return [3 /*break*/, 2];
77
+ _a = updatePackage;
78
+ return [4 /*yield*/, EsouiPublish.readFile(this.params.description)];
79
+ case 1:
80
+ _a.description = _c.sent();
81
+ _c.label = 2;
82
+ case 2:
83
+ if (!this.params.changelog) return [3 /*break*/, 4];
84
+ _b = updatePackage;
85
+ return [4 /*yield*/, EsouiPublish.readFile(this.params.changelog)];
86
+ case 3:
87
+ _b.changelog = _c.sent();
88
+ _c.label = 4;
89
+ case 4:
90
+ if (this.params.compatibility) {
91
+ updatePackage.compatibility = this.params.compatibility;
92
+ }
93
+ if (this.params.updatefile) {
94
+ updatePackage.updatefile = fs_1.default.createReadStream(this.params.updatefile);
95
+ }
96
+ return [2 /*return*/, updatePackage];
97
+ }
98
+ });
99
+ });
100
+ };
101
+ /**
102
+ * Performs update to esoui.
103
+ *
104
+ * @param updatePackage
105
+ *
106
+ */
107
+ EsouiPublish.prototype.updateEsoui = function (updatePackage) {
108
+ return __awaiter(this, void 0, void 0, function () {
109
+ var endpoint;
110
+ var _this = this;
111
+ return __generator(this, function (_a) {
112
+ endpoint = "https://api.esoui.com/addons/update" + (this.params.testDeploy ? 'test' : '');
113
+ if (this.params.testDeploy) {
114
+ console.warn('****TEST DEPLOYMENT****');
115
+ }
116
+ console.log("Publishing to " + endpoint);
117
+ return [2 /*return*/, new Promise(function (resolve, reject) {
118
+ var handleResponse = function (error, httpResponse, body) {
119
+ if (error) {
120
+ return reject(error);
121
+ }
122
+ if (httpResponse.statusCode !== 202) {
123
+ if (httpResponse.statusCode === 403) {
124
+ return reject('Unauthorized. Ensure correct token is set in `ESOUI_TOKEN` environment variable or provided via command line (--token=<you\'re token>)');
125
+ }
126
+ else {
127
+ return reject(body);
128
+ }
129
+ }
130
+ resolve({ responseStatusCode: httpResponse.statusCode, responseBody: JSON.parse(body), params: _this.params });
131
+ };
132
+ request_1.default.post({
133
+ headers: {
134
+ 'x-api-token': _this.token
135
+ },
136
+ url: endpoint,
137
+ formData: updatePackage
138
+ }, handleResponse);
139
+ })];
140
+ });
141
+ });
142
+ };
143
+ EsouiPublish.publish = function (token, id, version, description, changelog, compatibility, updateFile, test) {
144
+ return __awaiter(this, void 0, void 0, function () {
145
+ var params;
146
+ return __generator(this, function (_a) {
147
+ params = {
148
+ id: id,
149
+ version: version,
150
+ description: description,
151
+ changelog: changelog,
152
+ compatibility: compatibility,
153
+ updatefile: updateFile,
154
+ testDeploy: test
155
+ };
156
+ return [2 /*return*/, new EsouiPublish(token, params).createUpdatePackageAndUpdate()];
157
+ });
158
+ });
159
+ };
160
+ EsouiPublish.publishFromJson = function (jsonFile) {
161
+ return __awaiter(this, void 0, void 0, function () {
162
+ var _this = this;
163
+ return __generator(this, function (_a) {
164
+ return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
165
+ var json, _a, _b, error_1, token, params;
166
+ return __generator(this, function (_c) {
167
+ switch (_c.label) {
168
+ case 0:
169
+ _c.trys.push([0, 2, , 3]);
170
+ _b = (_a = JSON).parse;
171
+ return [4 /*yield*/, EsouiPublish.readFile(jsonFile)];
172
+ case 1:
173
+ json = _b.apply(_a, [_c.sent()]);
174
+ return [3 /*break*/, 3];
175
+ case 2:
176
+ error_1 = _c.sent();
177
+ return [2 /*return*/, reject(error_1)];
178
+ case 3:
179
+ if (json && json.id) {
180
+ token = json.token || process.env.ESOUI_TOKEN;
181
+ if (!token) {
182
+ return [2 /*return*/, reject('`token` not set in the JSON file or the ESOUI_TOKEN environment variable')];
183
+ }
184
+ params = { id: json.id };
185
+ json.version ? params.version = json.version : undefined;
186
+ json.description ? params.description = json.description : undefined;
187
+ json.changelog ? params.changelog = json.changelog : undefined;
188
+ json.compatibility ? params.compatibility = json.compatibility : undefined;
189
+ json.updateFile ? params.updatefile = json.updateFile : undefined;
190
+ json.test ? params.testDeploy = json.test : undefined;
191
+ resolve(new EsouiPublish(token, params).createUpdatePackageAndUpdate());
192
+ }
193
+ else {
194
+ return [2 /*return*/, reject('Missing `id`')];
195
+ }
196
+ return [2 /*return*/];
197
+ }
198
+ });
199
+ }); })];
200
+ });
201
+ });
202
+ };
203
+ EsouiPublish.readFile = function (file) {
204
+ return __awaiter(this, void 0, void 0, function () {
205
+ return __generator(this, function (_a) {
206
+ return [2 /*return*/, new Promise(function (resolve, reject) { return fs_1.default.readFile(file, 'utf8', function (error, data) {
207
+ if (error) {
208
+ reject(error);
209
+ }
210
+ else {
211
+ resolve(data);
212
+ }
213
+ }); })];
214
+ });
215
+ });
216
+ };
217
+ return EsouiPublish;
218
+ }());
219
+ exports.EsouiPublish = EsouiPublish;
220
220
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,41 +1,41 @@
1
- {
2
- "name": "esoui-publish",
3
- "version": "2.1.13",
4
- "description": "",
5
- "files": [
6
- "dist"
7
- ],
8
- "main": "./dist/index.js",
9
- "bin": {
10
- "esoui-publish": "./dist/bin.js"
11
- },
12
- "scripts": {
13
- "build": "npx tsc",
14
- "watch": "npx tsc -w",
15
- "check-version": "node ./.pipelines/util/ensure-version-upgraded.js"
16
- },
17
- "bugs": {
18
- "url": "https://dev.azure.com/MikeWestbrook/MikesNodeModules/_workitems/recentlyupdated/"
19
- },
20
- "homepage": "https://dev.azure.com/MikeWestbrook/MikesNodeModules/_git/esoui-publish?path=/README.md&_a=preview",
21
- "repository": {
22
- "type": "git",
23
- "url": "https://dev.azure.com/MikeWestbrook/MikesNodeModules/_git/esoui-publish"
24
- },
25
- "author": "Mike Westbrook",
26
- "license": "MIT",
27
- "dependencies": {
28
- "form-data": "^2.3.3",
29
- "request": "^2.88.0",
30
- "yargs": "^14.2.0"
31
- },
32
- "devDependencies": {
33
- "@types/node": "^12.12.8",
34
- "@types/request": "^2.48.3",
35
- "get-published-version": "^1.0.4",
36
- "jest": "^24.0.0",
37
- "typescript": "^3.7.2"
38
- },
39
- "elderScrollsOnlineAddonId": 2272,
40
- "elderScrollsOnlineCompatibility": "9.0.0"
41
- }
1
+ {
2
+ "name": "esoui-publish",
3
+ "version": "2.2.0",
4
+ "description": "",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "main": "./dist/index.js",
9
+ "bin": {
10
+ "esoui-publish": "dist/bin.js"
11
+ },
12
+ "scripts": {
13
+ "build": "npx tsc",
14
+ "watch": "npx tsc -w",
15
+ "check-version": "node ./.pipelines/util/ensure-version-upgraded.js"
16
+ },
17
+ "bugs": {
18
+ "url": "https://dev.azure.com/MikeWestbrook/MikesNodeModules/_workitems/recentlyupdated/"
19
+ },
20
+ "homepage": "https://dev.azure.com/MikeWestbrook/MikesNodeModules/_git/esoui-publish?path=/README.md&_a=preview",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://dev.azure.com/MikeWestbrook/MikesNodeModules/_git/esoui-publish"
24
+ },
25
+ "author": "Mike Westbrook",
26
+ "license": "MIT",
27
+ "dependencies": {
28
+ "form-data": "^2.3.3",
29
+ "request": "^2.88.0",
30
+ "yargs": "^14.2.0"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^12.12.8",
34
+ "@types/request": "^2.48.3",
35
+ "get-published-version": "^1.0.4",
36
+ "jest": "^24.0.0",
37
+ "typescript": "^3.7.2"
38
+ },
39
+ "elderScrollsOnlineAddonId": 2272,
40
+ "elderScrollsOnlineCompatibility": "9.0.0"
41
+ }