@pwrdrvr/microapps-publish 0.0.17 → 0.0.21

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.
Files changed (72) hide show
  1. package/bin/run +5 -0
  2. package/dist/commands/nextjs-docker-auto.d.ts +38 -0
  3. package/dist/commands/nextjs-docker-auto.d.ts.map +1 -0
  4. package/dist/commands/nextjs-docker-auto.js +415 -0
  5. package/dist/commands/nextjs-docker-auto.js.map +1 -0
  6. package/dist/commands/nextjs-version-restore.d.ts +14 -0
  7. package/dist/commands/nextjs-version-restore.d.ts.map +1 -0
  8. package/dist/commands/nextjs-version-restore.js +58 -0
  9. package/dist/commands/nextjs-version-restore.js.map +1 -0
  10. package/dist/commands/nextjs-version.d.ts +16 -0
  11. package/dist/commands/nextjs-version.d.ts.map +1 -0
  12. package/dist/commands/nextjs-version.js +94 -0
  13. package/dist/commands/nextjs-version.js.map +1 -0
  14. package/dist/commands/preflight.d.ts +15 -0
  15. package/dist/commands/preflight.d.ts.map +1 -0
  16. package/dist/commands/preflight.js +111 -0
  17. package/dist/commands/preflight.js.map +1 -0
  18. package/dist/commands/publish.d.ts +23 -0
  19. package/dist/commands/publish.d.ts.map +1 -0
  20. package/dist/commands/publish.js +300 -0
  21. package/dist/commands/publish.js.map +1 -0
  22. package/dist/config/Config.d.ts +0 -2
  23. package/dist/config/Config.d.ts.map +1 -1
  24. package/dist/config/Config.js +0 -5
  25. package/dist/config/Config.js.map +1 -1
  26. package/dist/index.d.ts +1 -30
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +3 -366
  29. package/dist/index.js.map +1 -1
  30. package/dist/lib/DeployClient.d.ts +34 -0
  31. package/dist/lib/DeployClient.d.ts.map +1 -0
  32. package/dist/{DeployClient.js → lib/DeployClient.js} +24 -5
  33. package/dist/lib/DeployClient.js.map +1 -0
  34. package/dist/lib/S3TransferUtility.d.ts +19 -0
  35. package/dist/lib/S3TransferUtility.d.ts.map +1 -0
  36. package/dist/{S3TransferUtility.js → lib/S3TransferUtility.js} +13 -0
  37. package/dist/lib/S3TransferUtility.js.map +1 -0
  38. package/dist/lib/S3Uploader.d.ts +27 -0
  39. package/dist/lib/S3Uploader.d.ts.map +1 -0
  40. package/dist/lib/S3Uploader.js +76 -0
  41. package/dist/lib/S3Uploader.js.map +1 -0
  42. package/dist/lib/Versions.d.ts +27 -0
  43. package/dist/lib/Versions.d.ts.map +1 -0
  44. package/dist/lib/Versions.js +76 -0
  45. package/dist/lib/Versions.js.map +1 -0
  46. package/package.json +11 -2
  47. package/src/commands/nextjs-docker-auto.ts +498 -0
  48. package/src/commands/nextjs-version-restore.ts +73 -0
  49. package/src/commands/nextjs-version.ts +113 -0
  50. package/src/commands/preflight.ts +121 -0
  51. package/src/commands/publish.ts +358 -0
  52. package/src/config/Config.ts +0 -4
  53. package/src/index.ts +1 -454
  54. package/src/{DeployClient.ts → lib/DeployClient.ts} +34 -11
  55. package/src/{S3TransferUtility.ts → lib/S3TransferUtility.ts} +15 -3
  56. package/src/{S3Uploader.ts → lib/S3Uploader.ts} +46 -11
  57. package/src/lib/Versions.ts +95 -0
  58. package/dist/DeployClient.d.ts +0 -15
  59. package/dist/DeployClient.d.ts.map +0 -1
  60. package/dist/DeployClient.js.map +0 -1
  61. package/dist/S3TransferUtility.d.ts +0 -6
  62. package/dist/S3TransferUtility.d.ts.map +0 -1
  63. package/dist/S3TransferUtility.js.map +0 -1
  64. package/dist/S3Uploader.d.ts +0 -8
  65. package/dist/S3Uploader.d.ts.map +0 -1
  66. package/dist/S3Uploader.js +0 -47
  67. package/dist/S3Uploader.js.map +0 -1
  68. package/dist/config/FileStore.d.ts +0 -7
  69. package/dist/config/FileStore.d.ts.map +0 -1
  70. package/dist/config/FileStore.js +0 -17
  71. package/dist/config/FileStore.js.map +0 -1
  72. package/src/config/FileStore.ts +0 -14
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const path = tslib_1.__importStar(require("path"));
5
+ const fs = tslib_1.__importStar(require("fs-extra"));
6
+ const S3TransferUtility_1 = tslib_1.__importDefault(require("./S3TransferUtility"));
7
+ class S3Uploader {
8
+ /**
9
+ * Copy files to local upload directory
10
+ * @param config
11
+ * @param s3UploadPath
12
+ * @param preflightResponse
13
+ */
14
+ static async CopyToUploadDir(config, s3UploadPath) {
15
+ const { destinationPrefix } = S3Uploader.ParseUploadPath(s3UploadPath);
16
+ // Make a local root dir for the upload
17
+ const tempUploadPath = path.join(S3Uploader._tempDir, destinationPrefix);
18
+ await S3Uploader.removeTempDirIfExists();
19
+ await fs.mkdir(tempUploadPath, { recursive: true });
20
+ // Copy the files in the source dir to the root dir
21
+ // Note: It would be faster to move the files, then move them back
22
+ await fs.copy(config.app.staticAssetsPath, tempUploadPath);
23
+ }
24
+ static ParseUploadPath(s3UploadPath) {
25
+ // Parse the S3 Source URI
26
+ const uri = new URL(s3UploadPath);
27
+ const bucketName = uri.host;
28
+ const destinationPrefix = uri.pathname.length >= 1 ? uri.pathname.slice(1) : '';
29
+ return { bucketName, destinationPrefix };
30
+ }
31
+ /**
32
+ * Upload files to S3
33
+ * @deprecated 2021-11-27
34
+ * @param config
35
+ * @param s3UploadPath
36
+ * @param preflightResponse
37
+ */
38
+ static async Upload(config, s3UploadPath, preflightResponse) {
39
+ try {
40
+ const { destinationPrefix, bucketName } = S3Uploader.ParseUploadPath(s3UploadPath);
41
+ // Make a local root dir for the upload
42
+ const tempUploadPath = path.join(S3Uploader._tempDir, destinationPrefix);
43
+ await S3Uploader.removeTempDirIfExists();
44
+ await fs.mkdir(tempUploadPath, { recursive: true });
45
+ // Copy the files in the source dir to the root dir
46
+ // Note: It would be faster to move the files, then move them back
47
+ // FIXME: Use p-map for controlled parallelism
48
+ await fs.copy(config.app.staticAssetsPath, tempUploadPath);
49
+ // Do the upload
50
+ await S3TransferUtility_1.default.UploadDir(this._tempDir, destinationPrefix, bucketName, preflightResponse);
51
+ }
52
+ finally {
53
+ // Delete the directory, now that it's uploaded or if we failed
54
+ await S3Uploader.removeTempDirIfExists();
55
+ }
56
+ }
57
+ static async removeTempDirIfExists() {
58
+ try {
59
+ const stats = await fs.stat(S3Uploader._tempDir);
60
+ if (stats.isDirectory()) {
61
+ await fs.rm(S3Uploader._tempDir, { recursive: true });
62
+ }
63
+ }
64
+ catch (_a) {
65
+ // Don't care
66
+ // fs.stat will throw if file/dir does not exist
67
+ // Since we want the directory deleted this is ok
68
+ }
69
+ }
70
+ static get TempDir() {
71
+ return S3Uploader._tempDir;
72
+ }
73
+ }
74
+ exports.default = S3Uploader;
75
+ S3Uploader._tempDir = './deploytool-temp';
76
+ //# sourceMappingURL=S3Uploader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"S3Uploader.js","sourceRoot":"","sources":["../../src/lib/S3Uploader.ts"],"names":[],"mappings":";;;AAAA,mDAA6B;AAE7B,qDAA+B;AAE/B,oFAAoD;AAEpD,MAAqB,UAAU;IAC7B;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,MAAe,EAAE,YAAoB;QACvE,MAAM,EAAE,iBAAiB,EAAE,GAAG,UAAU,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QAEvE,uCAAuC;QACvC,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;QACzE,MAAM,UAAU,CAAC,qBAAqB,EAAE,CAAC;QACzC,MAAM,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAEpD,mDAAmD;QACnD,kEAAkE;QAClE,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;IAC7D,CAAC;IAEM,MAAM,CAAC,eAAe,CAAC,YAAoB;QAIhD,0BAA0B;QAC1B,MAAM,GAAG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AAQ,CAAC,CAAC;YACjD,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE;gBACvB,MAAM,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;aACvD;SACF;QAAC,WAAM;YACN,aAAa;YACb,gDAAgD;YAChD,iDAAiD;SAClD;IACH,CAAC;IAGM,MAAM,KAAK,OAAO;QACvB,OAAO,UAAU,CAAC,QAAQ,CAAC;IAC7B,CAAC;;AAtFH,6BAuFC;AAJyB,mBAAQ,GAAG,mBAAmB,CAAC"}
@@ -0,0 +1,27 @@
1
+ export interface IVersions {
2
+ version: string;
3
+ alias?: string;
4
+ }
5
+ export interface IFileToModify {
6
+ path: string;
7
+ versions: IVersions;
8
+ }
9
+ /**
10
+ * Setup version and alias strings
11
+ * @param version
12
+ * @returns
13
+ */
14
+ export declare function createVersions(version: string): IVersions;
15
+ /**
16
+ * Write new versions into specified config file
17
+ * @param path
18
+ * @param requiredVersions
19
+ * @param leaveFiles
20
+ * @returns
21
+ */
22
+ export declare function writeNewVersions(path: string, requiredVersions: IVersions, leaveFiles: boolean): Promise<boolean>;
23
+ /**
24
+ * Restore files that the version was patched into
25
+ */
26
+ export declare function restoreFiles(filesToModify: IFileToModify[]): Promise<void>;
27
+ //# sourceMappingURL=Versions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Versions.d.ts","sourceRoot":"","sources":["../../src/lib/Versions.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,SAAS,CAAC;CACrB;AAOD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAEzD;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,SAAS,EAC3B,UAAU,EAAE,OAAO,GAClB,OAAO,CAAC,OAAO,CAAC,CAoClB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,aAAa,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBhF"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.restoreFiles = exports.writeNewVersions = exports.createVersions = void 0;
4
+ const fs_extra_1 = require("fs-extra");
5
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
6
+ function escapeRegExp(value) {
7
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
8
+ }
9
+ /**
10
+ * Setup version and alias strings
11
+ * @param version
12
+ * @returns
13
+ */
14
+ function createVersions(version) {
15
+ return { version, alias: `v${version.replace(/\./g, '_')}` };
16
+ }
17
+ exports.createVersions = createVersions;
18
+ /**
19
+ * Write new versions into specified config file
20
+ * @param path
21
+ * @param requiredVersions
22
+ * @param leaveFiles
23
+ * @returns
24
+ */
25
+ async function writeNewVersions(path, requiredVersions, leaveFiles) {
26
+ const stats = await fs_extra_1.promises.stat(path);
27
+ if (!stats.isFile) {
28
+ return false;
29
+ }
30
+ // Make a backup of the file
31
+ await fs_extra_1.promises.copyFile(path, `${path}.original`);
32
+ // File exists, check that it has the required version strings
33
+ let fileText = await fs_extra_1.promises.readFile(path, 'utf8');
34
+ for (const key of Object.keys(requiredVersions)) {
35
+ const placeHolder = key === 'version' ? '0.0.0' : 'v0_0_0';
36
+ if (fileText.indexOf(placeHolder) === -1) {
37
+ // The required placeholder is missing
38
+ return false;
39
+ }
40
+ else {
41
+ const regExp = new RegExp(escapeRegExp(placeHolder), 'g');
42
+ fileText = fileText.replace(regExp, key === 'version' ? requiredVersions.version : requiredVersions.alias);
43
+ }
44
+ }
45
+ // Write the updated file contents
46
+ await fs_extra_1.promises.writeFile(path, fileText, 'utf8');
47
+ // Leave a copy of the modified file if requested
48
+ if (leaveFiles) {
49
+ // This copy will overwrite an existing file
50
+ await fs_extra_1.promises.copyFile(path, `${path}.modified`);
51
+ }
52
+ return true;
53
+ }
54
+ exports.writeNewVersions = writeNewVersions;
55
+ /**
56
+ * Restore files that the version was patched into
57
+ */
58
+ async function restoreFiles(filesToModify) {
59
+ // Put the old files back when succeeded or failed
60
+ for (const fileToModify of filesToModify) {
61
+ try {
62
+ const stats = await fs_extra_1.promises.stat(`${fileToModify.path}.original`);
63
+ if (stats.isFile()) {
64
+ // Remove the possibly modified file
65
+ await fs_extra_1.promises.unlink(fileToModify.path);
66
+ // Move the original file back
67
+ await fs_extra_1.promises.rename(`${fileToModify.path}.original`, fileToModify.path);
68
+ }
69
+ }
70
+ catch (_a) {
71
+ // don't care... if the file doesn't exist we can't do anything
72
+ }
73
+ }
74
+ }
75
+ exports.restoreFiles = restoreFiles;
76
+ //# sourceMappingURL=Versions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Versions.js","sourceRoot":"","sources":["../../src/lib/Versions.ts"],"names":[],"mappings":";;;AAAA,uCAA0C;AAY1C,6FAA6F;AAC7F,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,CAAC,oCAAoC;AAC3F,CAAC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAC,OAAe;IAC5C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;AAC/D,CAAC;AAFD,wCAEC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,gBAAgB,CACpC,IAAY,EACZ,gBAA2B,EAC3B,UAAmB;IAEnB,MAAM,KAAK,GAAG,MAAM,mBAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;I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I;YACF,MAAM,KAAK,GAAG,MAAM,mBAAE,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,IAAI,WAAW,CAAC,CAAC;YAC7D,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;gBAClB,oCAAoC;gBACpC,MAAM,mBAAE,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;gBAEnC,8BAA8B;gBAC9B,MAAM,mBAAE,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,IAAI,WAAW,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;aACrE;SACF;QAAC,WAAM;YACN,+DAA+D;SAChE;KACF;AACH,CAAC;AAhBD,oCAgBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pwrdrvr/microapps-publish",
3
- "version": "0.0.17",
3
+ "version": "0.0.21",
4
4
  "description": "Publish tool for deploying apps and updates",
5
5
  "main": "dist/index.js",
6
6
  "source": "src/index.ts",
@@ -8,7 +8,7 @@
8
8
  "access": "public"
9
9
  },
10
10
  "bin": {
11
- "microapps-publish": "dist/index.js"
11
+ "microapps-publish": "./bin/run"
12
12
  },
13
13
  "engineStrict": true,
14
14
  "engine": {
@@ -41,7 +41,9 @@
41
41
  "@aws-sdk/lib-storage": "^3.20.0",
42
42
  "@oclif/command": "^1.8.4",
43
43
  "@oclif/config": "^1.17.1",
44
+ "@oclif/core": "^1.0.4",
44
45
  "@oclif/errors": "^1.3.5",
46
+ "@oclif/plugin-help": "^3.2.7",
45
47
  "chalk": "^4.1.2",
46
48
  "commander": "^7.1.0",
47
49
  "convict": "^6.1.0",
@@ -64,5 +66,12 @@
64
66
  "@types/mime-types": "^2.1.0",
65
67
  "@types/source-map-support": "^0.5.4",
66
68
  "type-fest": "^0.20.2"
69
+ },
70
+ "oclif": {
71
+ "commands": "./dist/commands/",
72
+ "bin": "microapps-publish",
73
+ "plugins": [
74
+ "@oclif/plugin-help"
75
+ ]
67
76
  }
68
77
  }