@microsoft/windows-admin-center-sdk 4.52.0 → 4.123.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.
Files changed (134) hide show
  1. package/angular/esm2020/src/controls/actions/containers/action-bar/action-bar.component.mjs +2 -2
  2. package/angular/esm2020/src/controls/master-view/master-view.component.mjs +8 -6
  3. package/angular/esm2020/src/controls/ux/sme-ux-footer/sme-ux-footer-template/sme-wizard-lite-footer-template/sme-wizard-lite-footer-template.component.mjs +56 -1
  4. package/angular/esm2020/src/service/navigation.service.mjs +3 -1
  5. package/angular/fesm2015/microsoft-windows-admin-center-sdk-angular.mjs +66 -6
  6. package/angular/fesm2015/microsoft-windows-admin-center-sdk-angular.mjs.map +1 -1
  7. package/angular/fesm2020/microsoft-windows-admin-center-sdk-angular.mjs +65 -6
  8. package/angular/fesm2020/microsoft-windows-admin-center-sdk-angular.mjs.map +1 -1
  9. package/angular/src/controls/master-view/master-view.component.d.ts +6 -2
  10. package/angular/src/controls/ux/sme-ux-footer/sme-ux-footer-template/sme-wizard-lite-footer-template/sme-wizard-lite-footer-template.component.d.ts +64 -0
  11. package/core/assets/strings/cs-CZ/strings.json +1 -1
  12. package/core/assets/strings/de-DE/strings.json +1 -1
  13. package/core/assets/strings/es-ES/strings.json +1 -1
  14. package/core/assets/strings/fr-FR/strings.json +1 -1
  15. package/core/assets/strings/hu-HU/strings.json +1 -1
  16. package/core/assets/strings/id-ID/strings.json +1 -1
  17. package/core/assets/strings/it-IT/strings.json +1 -1
  18. package/core/assets/strings/ja-JP/strings.json +1 -1
  19. package/core/assets/strings/ko-KR/strings.json +1 -1
  20. package/core/assets/strings/nl-NL/strings.json +1 -1
  21. package/core/assets/strings/pl-PL/strings.json +1 -1
  22. package/core/assets/strings/pt-BR/strings.json +1 -1
  23. package/core/assets/strings/pt-PT/strings.json +1 -1
  24. package/core/assets/strings/ru-RU/strings.json +1 -1
  25. package/core/assets/strings/strings.json +1 -1
  26. package/core/assets/strings/sv-SE/strings.json +1 -1
  27. package/core/assets/strings/tr-TR/strings.json +1 -1
  28. package/core/assets/strings/zh-CN/strings.json +1 -1
  29. package/core/assets/strings/zh-TW/strings.json +1 -1
  30. package/core/azure/azure-constants.d.ts +7 -3
  31. package/core/azure/azure-constants.d.ts.map +1 -1
  32. package/core/azure/azure-constants.js +8 -4
  33. package/core/azure/azure-constants.js.map +1 -1
  34. package/core/azure/models/azureArcStatusEnum.d.ts +4 -2
  35. package/core/azure/models/azureArcStatusEnum.d.ts.map +1 -1
  36. package/core/azure/models/azureArcStatusEnum.js +3 -1
  37. package/core/azure/models/azureArcStatusEnum.js.map +1 -1
  38. package/core/base/utilities.d.ts +3 -3
  39. package/core/base/utilities.d.ts.map +1 -1
  40. package/core/base/utilities.js +2 -2
  41. package/core/base/utilities.js.map +1 -1
  42. package/core/data/active-directory/active-directory.d.ts.map +1 -1
  43. package/core/data/active-directory/active-directory.js +1 -1
  44. package/core/data/active-directory/active-directory.js.map +1 -1
  45. package/core/data/cookie.d.ts.map +1 -1
  46. package/core/data/cookie.js +7 -0
  47. package/core/data/cookie.js.map +1 -1
  48. package/core/data/gateway-connection.d.ts +12 -0
  49. package/core/data/gateway-connection.d.ts.map +1 -1
  50. package/core/data/gateway-connection.js +16 -0
  51. package/core/data/gateway-connection.js.map +1 -1
  52. package/core/data/gateway-url-translator.d.ts +1 -0
  53. package/core/data/gateway-url-translator.d.ts.map +1 -1
  54. package/core/data/gateway-url-translator.js +15 -0
  55. package/core/data/gateway-url-translator.js.map +1 -1
  56. package/core/data/gateway-urls.d.ts +6 -0
  57. package/core/data/gateway-urls.d.ts.map +1 -1
  58. package/core/data/gateway-urls.js +8 -0
  59. package/core/data/gateway-urls.js.map +1 -1
  60. package/core/data/net.d.ts +1 -0
  61. package/core/data/net.d.ts.map +1 -1
  62. package/core/data/net.js +26 -1
  63. package/core/data/net.js.map +1 -1
  64. package/core/data/websocket-stream.d.ts.map +1 -1
  65. package/core/data/websocket-stream.js +2 -2
  66. package/core/data/websocket-stream.js.map +1 -1
  67. package/core/generated/powershell-scripts.d.ts.map +1 -1
  68. package/core/generated/powershell-scripts.js +1 -1
  69. package/core/generated/powershell-scripts.js.map +1 -1
  70. package/core/generated/strings.d.ts +3 -0
  71. package/core/generated/strings.d.ts.map +1 -1
  72. package/core/generated/strings.js.map +1 -1
  73. package/core/notification/notification.d.ts.map +1 -1
  74. package/core/notification/notification.js +1 -3
  75. package/core/notification/notification.js.map +1 -1
  76. package/core/resources/scripts/public/inventory/Get-ServerInventory.ps1 +8 -8
  77. package/core/security/tool-condition-validator.d.ts.map +1 -1
  78. package/core/security/tool-condition-validator.js +5 -5
  79. package/core/security/tool-condition-validator.js.map +1 -1
  80. package/core/shared/server-inventory/server-inventory-cache.d.ts.map +1 -1
  81. package/core/shared/server-inventory/server-inventory-cache.js +1 -2
  82. package/core/shared/server-inventory/server-inventory-cache.js.map +1 -1
  83. package/core/shared/server-inventory/server-inventory.d.ts +4 -4
  84. package/core/shared/server-inventory/server-inventory.d.ts.map +1 -1
  85. package/core/shared/server-inventory/server-inventory.js +2 -2
  86. package/core/shared/server-inventory/server-inventory.js.map +1 -1
  87. package/microsoft-windows-admin-center-sdk-4.123.0.tgz +0 -0
  88. package/package.json +4 -4
  89. package/styles/css/main-v2.css +1 -1
  90. package/tools/module-template/build/pipelines/ci-build.yml +2 -2
  91. package/tools/wac-cli/src/angular15/configs/angular-json-config.d.ts +2 -7
  92. package/tools/wac-cli/src/angular15/configs/angular-json-config.d.ts.map +1 -1
  93. package/tools/wac-cli/src/angular15/configs/angular-json-config.js +8 -1
  94. package/tools/wac-cli/src/angular15/configs/angular-json-config.js.map +1 -1
  95. package/tools/wac-cli/src/angular15/configs/package-json-config.d.ts +4 -0
  96. package/tools/wac-cli/src/angular15/configs/package-json-config.d.ts.map +1 -1
  97. package/tools/wac-cli/src/angular15/configs/package-json-config.js +13 -9
  98. package/tools/wac-cli/src/angular15/configs/package-json-config.js.map +1 -1
  99. package/tools/wac-cli/src/angular15/configs/ui-test-automation-lagacy-config.d.ts +14 -0
  100. package/tools/wac-cli/src/angular15/configs/ui-test-automation-lagacy-config.d.ts.map +1 -0
  101. package/tools/wac-cli/src/angular15/configs/ui-test-automation-lagacy-config.js +21 -0
  102. package/tools/wac-cli/src/angular15/configs/ui-test-automation-lagacy-config.js.map +1 -0
  103. package/tools/wac-cli/src/angular15/main.d.ts +33 -3
  104. package/tools/wac-cli/src/angular15/main.d.ts.map +1 -1
  105. package/tools/wac-cli/src/angular15/main.js +69 -7
  106. package/tools/wac-cli/src/angular15/main.js.map +1 -1
  107. package/tools/wac-cli/src/angular15/test/ui-test-automation-package.json/after.json +14 -0
  108. package/tools/wac-cli/src/angular15/test/ui-test-automation-package.json/before.json +13 -0
  109. package/tools/wac-cli/src/angular15/upgrader/ui-test-automation-legacy-upgrader.d.ts +15 -0
  110. package/tools/wac-cli/src/angular15/upgrader/ui-test-automation-legacy-upgrader.d.ts.map +1 -0
  111. package/tools/wac-cli/src/angular15/upgrader/ui-test-automation-legacy-upgrader.js +48 -0
  112. package/tools/wac-cli/src/angular15/upgrader/ui-test-automation-legacy-upgrader.js.map +1 -0
  113. package/tools/wac-cli/src/angular15/utils/main-debugger.d.ts.map +1 -1
  114. package/tools/wac-cli/src/angular15/utils/main-debugger.js +3 -0
  115. package/tools/wac-cli/src/angular15/utils/main-debugger.js.map +1 -1
  116. package/tools/wac-cli/src/angular15/utils/update-shell-references.d.ts +2 -0
  117. package/tools/wac-cli/src/angular15/utils/update-shell-references.d.ts.map +1 -0
  118. package/tools/wac-cli/src/angular15/utils/update-shell-references.js +69 -0
  119. package/tools/wac-cli/src/angular15/utils/update-shell-references.js.map +1 -0
  120. package/tools/wac-cli/src/common.d.ts +6 -0
  121. package/tools/wac-cli/src/common.d.ts.map +1 -1
  122. package/tools/wac-cli/src/common.js +13 -0
  123. package/tools/wac-cli/src/common.js.map +1 -1
  124. package/tools/wac-cli/src/create/main.d.ts.map +1 -1
  125. package/tools/wac-cli/src/create/main.js +3 -51
  126. package/tools/wac-cli/src/create/main.js.map +1 -1
  127. package/tools/wac-cli/src/eslint/main.d.ts +5 -1
  128. package/tools/wac-cli/src/eslint/main.d.ts.map +1 -1
  129. package/tools/wac-cli/src/eslint/main.js +17 -2
  130. package/tools/wac-cli/src/eslint/main.js.map +1 -1
  131. package/tools/wac-cli/src/index.d.ts.map +1 -1
  132. package/tools/wac-cli/src/index.js +2 -2
  133. package/tools/wac-cli/src/index.js.map +1 -1
  134. package/tools/wac-cli/templates/wac-template/package.json +3 -0
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cleanFile = exports.updateShellReferences = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
6
+ const logger_1 = require("./logger");
7
+ function updateShellReferences(primaryDisplayName, internal) {
8
+ logger_1.Logger.log('Updating shell references...');
9
+ logger_1.Logger.log('Detected internal: ' + internal);
10
+ const internalShellReference = '@msft-sme';
11
+ const externalShellReference = '@microsoft/windows-admin-center-sdk';
12
+ const find = internal ? externalShellReference : internalShellReference;
13
+ const replace = internal ? internalShellReference : externalShellReference;
14
+ // For performance reasons, all applicable files are listed here, rather than scanning all files
15
+ const extensionDirectory = ('./' + primaryDisplayName + '/').replace('//', '/');
16
+ const extensionSrcDirectory = extensionDirectory + 'src/';
17
+ const extensionAppDirectory = extensionSrcDirectory + 'app/';
18
+ const gulpFileDirectory = extensionDirectory + 'gulpfile.ts/';
19
+ const gulpFileCommonDirectory = gulpFileDirectory + 'common/';
20
+ const filesWithShellReferences = [
21
+ extensionDirectory + 'angular.json',
22
+ gulpFileDirectory + 'config-data.ts',
23
+ gulpFileDirectory + 'index.ts',
24
+ gulpFileCommonDirectory + 'pack.ts',
25
+ gulpFileCommonDirectory + 'powershell.ts',
26
+ gulpFileCommonDirectory + 'resjson.ts',
27
+ gulpFileCommonDirectory + 'test.ts',
28
+ gulpFileCommonDirectory + 'validate.ts',
29
+ extensionSrcDirectory + 'main.ts',
30
+ extensionSrcDirectory + 'manifest.json',
31
+ extensionSrcDirectory + 'polyfills.ts',
32
+ extensionSrcDirectory + 'test.ts',
33
+ extensionAppDirectory + 'app-routing.module.ts',
34
+ extensionAppDirectory + 'app.component.ts',
35
+ extensionAppDirectory + 'app.module.ts',
36
+ extensionDirectory + '.eslintrc.json'
37
+ ];
38
+ const cleanFiles = {};
39
+ filesWithShellReferences.forEach((file) => {
40
+ cleanFiles[file] = {
41
+ [find]: replace
42
+ };
43
+ });
44
+ for (const key in cleanFiles) {
45
+ if (Object.prototype.hasOwnProperty.call(cleanFiles, key)) {
46
+ cleanFile(key, cleanFiles[key]);
47
+ }
48
+ }
49
+ }
50
+ exports.updateShellReferences = updateShellReferences;
51
+ function cleanFile(key, values) {
52
+ logger_1.Logger.log('Updating: ' + key + ' ' + JSON.stringify(values));
53
+ for (const valuesKey in values) {
54
+ let a = 0;
55
+ if (Object.prototype.hasOwnProperty.call(values, valuesKey)) {
56
+ let fileData = fs_extra_1.default.readFileSync(key, 'utf8');
57
+ let displayNameIndex = fileData.indexOf(valuesKey);
58
+ while (displayNameIndex > 0) {
59
+ logger_1.Logger.log('Found key: ' + valuesKey + ' at index: ' + displayNameIndex);
60
+ fileData = fileData.replace(valuesKey, values[valuesKey]);
61
+ displayNameIndex = fileData.indexOf(valuesKey);
62
+ }
63
+ fs_extra_1.default.outputFileSync(key, fileData);
64
+ }
65
+ }
66
+ }
67
+ exports.cleanFile = cleanFile;
68
+
69
+ //# sourceMappingURL=update-shell-references.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../packages/tools/wac-cli/src/angular15/utils/update-shell-references.ts"],"names":[],"mappings":";;;;AAAA,gEAA2B;AAC3B,qCAAkC;AAElC,SAAgB,qBAAqB,CAAC,kBAA0B,EAAE,QAAiB;IAC/E,eAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;IAC3C,e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ell-references.js","sourcesContent":["import fse from 'fs-extra';\r\nimport { Logger } from \"./logger\";\r\n\r\nexport function updateShellReferences(primaryDisplayName: string, internal: boolean): void {\r\n Logger.log('Updating shell references...');\r\n Logger.log('Detected internal: ' + internal);\r\n const internalShellReference = '@msft-sme';\r\n const externalShellReference = '@microsoft/windows-admin-center-sdk';\r\n const find = internal ? externalShellReference : internalShellReference;\r\n const replace = internal ? internalShellReference : externalShellReference;\r\n\r\n // For performance reasons, all applicable files are listed here, rather than scanning all files\r\n const extensionDirectory = ('./' + primaryDisplayName + '/').replace('//', '/');\r\n const extensionSrcDirectory = extensionDirectory + 'src/';\r\n const extensionAppDirectory = extensionSrcDirectory + 'app/';\r\n const gulpFileDirectory = extensionDirectory + 'gulpfile.ts/';\r\n const gulpFileCommonDirectory = gulpFileDirectory + 'common/';\r\n\r\n const filesWithShellReferences = [\r\n extensionDirectory + 'angular.json',\r\n gulpFileDirectory + 'config-data.ts',\r\n gulpFileDirectory + 'index.ts',\r\n gulpFileCommonDirectory + 'pack.ts',\r\n gulpFileCommonDirectory + 'powershell.ts',\r\n gulpFileCommonDirectory + 'resjson.ts',\r\n gulpFileCommonDirectory + 'test.ts',\r\n gulpFileCommonDirectory + 'validate.ts',\r\n extensionSrcDirectory + 'main.ts',\r\n extensionSrcDirectory + 'manifest.json',\r\n extensionSrcDirectory + 'polyfills.ts',\r\n extensionSrcDirectory + 'test.ts',\r\n extensionAppDirectory + 'app-routing.module.ts',\r\n extensionAppDirectory + 'app.component.ts',\r\n extensionAppDirectory + 'app.module.ts',\r\n extensionDirectory + '.eslintrc.json'\r\n ];\r\n\r\n const cleanFiles = {};\r\n\r\n filesWithShellReferences.forEach((file) => {\r\n cleanFiles[file] = {\r\n [find]: replace\r\n };\r\n });\r\n\r\n for (const key in cleanFiles) {\r\n if (Object.prototype.hasOwnProperty.call(cleanFiles, key)) {\r\n cleanFile(key, cleanFiles[key]);\r\n }\r\n }\r\n}\r\n\r\nexport function cleanFile(key: string, values: any): void {\r\n Logger.log('Updating: ' + key + ' ' + JSON.stringify(values));\r\n for (const valuesKey in values) {\r\n let a = 0;\r\n if (Object.prototype.hasOwnProperty.call(values, valuesKey)) {\r\n let fileData = fse.readFileSync(key, 'utf8');\r\n let displayNameIndex = fileData.indexOf(valuesKey);\r\n\r\n while (displayNameIndex > 0) {\r\n Logger.log('Found key: ' + valuesKey + ' at index: ' + displayNameIndex);\r\n fileData = fileData.replace(valuesKey, values[valuesKey]);\r\n displayNameIndex = fileData.indexOf(valuesKey);\r\n }\r\n\r\n fse.outputFileSync(key, fileData);\r\n }\r\n }\r\n}"]}
@@ -31,6 +31,12 @@ export declare class Common {
31
31
  * @returns {boolean} indicates whether the file was written successfully.
32
32
  */
33
33
  static writeFileData(filePath: any, newContent: any): boolean;
34
+ /**
35
+ * Creates the file with content.
36
+ * @param {string} filePath Target file path
37
+ * @param {string} newContent Content to write to the file
38
+ */
39
+ static writeFile(filePath: any, newContent: any): Promise<void>;
34
40
  /**
35
41
  * Retrieves content of given JSON file and parses into an object
36
42
  * @param {string} filePath Target file path
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../packages/tools/wac-cli/src/common.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,oBAAY,YAAY;IACpB,QAAQ,aAAa;IACrB,UAAU,eAAe;CAC5B;AAED,qBAAa,MAAM;IACf,gBAAuB,WAAW,SAAgD;IAClF,gBAAuB,kBAAkB,SAAuE;IAEhH,OAAO,CAAC,MAAM,CAAC,SAAS,CAAS;IAEjC;;;OAGG;IACH,WAAkB,QAAQ,WAEzB;IAED;;;OAGG;IACH,WAAkB,QAAQ,CAAC,IAAI,QAAA,EAE9B;IAED;;;;OAIG;WACW,YAAY,CAAC,QAAQ,KAAA;IAYnC;;;;OAIG;WACW,aAAa,CAAC,QAAQ,KAAA,EAAE,UAAU,KAAA,GAAG,OAAO;IAc1D;;;;OAIG;WACW,YAAY,CAAC,QAAQ,KAAA;IAYnC;;;;;;OAMG;WACW,eAAe,CAAC,cAAc,KAAA,EAAE,cAAc,KAAA,EAAE,SAAS,KAAA;CAG1E","file":"common.d.ts","sourcesContent":["const fs = require('fs');\r\nconst fse = require('fs-extra');\r\n\r\n/**\r\n * Error resolution states\r\n */\r\nexport enum ResolveState {\r\n Resolved = 'RESOLVED',\r\n Unresolved = 'UNRESOLVED'\r\n}\r\n\r\nexport class Common {\r\n public static readonly cliRootPath = __dirname.substring(0, __dirname.length - 3);\r\n public static readonly moduleTemplatePath = __dirname.substring(0, __dirname.length - 11) + 'module-template\\\\';\r\n\r\n private static _rootPath: string;\r\n\r\n /**\r\n * Gets the root path for the current repository\r\n * @returns {string} Root path for the current repository\r\n */\r\n public static get rootPath() {\r\n return Common._rootPath;\r\n }\r\n\r\n /**\r\n * Sets the root path for the current repository\r\n * @param {string} path Root path for the current repository\r\n */\r\n public static set rootPath(path) {\r\n Common._rootPath = path;\r\n }\r\n\r\n /**\r\n * Retrieves content of given file\r\n * @param {string} filePath Target file path\r\n * @returns {string | null} String representation of file content or null if file was not found\r\n */\r\n public static readFileData(filePath) {\r\n if (!fs.statSync(filePath).isDirectory()) {\r\n if (!fse.existsSync(filePath)) {\r\n return null;\r\n }\r\n\r\n return fse.readFileSync(filePath, 'utf8');\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Writes to the content of given file\r\n * @param {string} filePath Target file path\r\n * @returns {boolean} indicates whether the file was written successfully.\r\n */\r\n public static writeFileData(filePath, newContent): boolean {\r\n if (!fs.statSync(filePath).isDirectory()) {\r\n if (!fse.existsSync(filePath)) {\r\n return false;\r\n }\r\n\r\n fse.writeFileSync(filePath, newContent, 'utf8');\r\n\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Retrieves content of given JSON file and parses into an object\r\n * @param {string} filePath Target file path\r\n * @returns {any | null} Parsed JSON object or null if file was not found\r\n */\r\n public static readFileJSON(filePath) {\r\n if (!fs.statSync(filePath).isDirectory()) {\r\n if (!fse.existsSync(filePath)) {\r\n return null;\r\n }\r\n\r\n return fse.readJSONSync(filePath);\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Replaces part of target string with a new string using given regex\r\n * @param {string} originalString Target string\r\n * @param {RegExp} regexToReplace Regex to apply to target string\r\n * @param {string} newString String that will replace regex matches\r\n * @returns {string} New string created from replacing regex matches or original string if no matches were found\r\n */\r\n public static replaceInString(originalString, regexToReplace, newString) {\r\n return originalString.replace(regexToReplace, newString);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"sources":["../../../packages/tools/wac-cli/src/common.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,oBAAY,YAAY;IACpB,QAAQ,aAAa;IACrB,UAAU,eAAe;CAC5B;AAED,qBAAa,MAAM;IACf,gBAAuB,WAAW,SAAgD;IAClF,gBAAuB,kBAAkB,SAAuE;IAEhH,OAAO,CAAC,MAAM,CAAC,SAAS,CAAS;IAEjC;;;OAGG;IACH,WAAkB,QAAQ,WAEzB;IAED;;;OAGG;IACH,WAAkB,QAAQ,CAAC,IAAI,QAAA,EAE9B;IAED;;;;OAIG;WACW,YAAY,CAAC,QAAQ,KAAA;IAYnC;;;;OAIG;WACW,aAAa,CAAC,QAAQ,KAAA,EAAE,UAAU,KAAA,GAAG,OAAO;IAc1D;;;;OAIG;WACiB,SAAS,CAAC,QAAQ,KAAA,EAAE,UAAU,KAAA,GAAG,OAAO,CAAC,IAAI,CAAC;IASlE;;;;OAIG;WACW,YAAY,CAAC,QAAQ,KAAA;IAYnC;;;;;;OAMG;WACW,eAAe,CAAC,cAAc,KAAA,EAAE,cAAc,KAAA,EAAE,SAAS,KAAA;CAG1E","file":"common.d.ts","sourcesContent":["const fs = require('fs');\r\nconst fse = require('fs-extra');\r\n\r\n/**\r\n * Error resolution states\r\n */\r\nexport enum ResolveState {\r\n Resolved = 'RESOLVED',\r\n Unresolved = 'UNRESOLVED'\r\n}\r\n\r\nexport class Common {\r\n public static readonly cliRootPath = __dirname.substring(0, __dirname.length - 3);\r\n public static readonly moduleTemplatePath = __dirname.substring(0, __dirname.length - 11) + 'module-template\\\\';\r\n\r\n private static _rootPath: string;\r\n\r\n /**\r\n * Gets the root path for the current repository\r\n * @returns {string} Root path for the current repository\r\n */\r\n public static get rootPath() {\r\n return Common._rootPath;\r\n }\r\n\r\n /**\r\n * Sets the root path for the current repository\r\n * @param {string} path Root path for the current repository\r\n */\r\n public static set rootPath(path) {\r\n Common._rootPath = path;\r\n }\r\n\r\n /**\r\n * Retrieves content of given file\r\n * @param {string} filePath Target file path\r\n * @returns {string | null} String representation of file content or null if file was not found\r\n */\r\n public static readFileData(filePath) {\r\n if (!fs.statSync(filePath).isDirectory()) {\r\n if (!fse.existsSync(filePath)) {\r\n return null;\r\n }\r\n\r\n return fse.readFileSync(filePath, 'utf8');\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Writes to the content of given file\r\n * @param {string} filePath Target file path\r\n * @returns {boolean} indicates whether the file was written successfully.\r\n */\r\n public static writeFileData(filePath, newContent): boolean {\r\n if (!fs.statSync(filePath).isDirectory()) {\r\n if (!fse.existsSync(filePath)) {\r\n return false;\r\n }\r\n\r\n fse.writeFileSync(filePath, newContent, 'utf8');\r\n\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Creates the file with content.\r\n * @param {string} filePath Target file path\r\n * @param {string} newContent Content to write to the file\r\n */\r\n public static async writeFile(filePath, newContent): Promise<void> {\r\n await fs.writeFile(filePath, newContent, (err) => {\r\n if (err) {\r\n console.error('Error creating file:', err);\r\n return;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Retrieves content of given JSON file and parses into an object\r\n * @param {string} filePath Target file path\r\n * @returns {any | null} Parsed JSON object or null if file was not found\r\n */\r\n public static readFileJSON(filePath) {\r\n if (!fs.statSync(filePath).isDirectory()) {\r\n if (!fse.existsSync(filePath)) {\r\n return null;\r\n }\r\n\r\n return fse.readJSONSync(filePath);\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Replaces part of target string with a new string using given regex\r\n * @param {string} originalString Target string\r\n * @param {RegExp} regexToReplace Regex to apply to target string\r\n * @param {string} newString String that will replace regex matches\r\n * @returns {string} New string created from replacing regex matches or original string if no matches were found\r\n */\r\n public static replaceInString(originalString, regexToReplace, newString) {\r\n return originalString.replace(regexToReplace, newString);\r\n }\r\n}\r\n"]}
@@ -58,6 +58,19 @@ class Common {
58
58
  }
59
59
  return false;
60
60
  }
61
+ /**
62
+ * Creates the file with content.
63
+ * @param {string} filePath Target file path
64
+ * @param {string} newContent Content to write to the file
65
+ */
66
+ static async writeFile(filePath, newContent) {
67
+ await fs.writeFile(filePath, newContent, (err) => {
68
+ if (err) {
69
+ console.error('Error creating file:', err);
70
+ return;
71
+ }
72
+ });
73
+ }
61
74
  /**
62
75
  * Retrieves content of given JSON file and parses into an object
63
76
  * @param {string} filePath Target file path
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../packages/tools/wac-cli/src/common.ts"],"names":[],"mappings":";;;AAAA,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACzB,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEhC;;GAEG;AACH,IAAY,YAGX;AAHD,WAAY,YAAY;IACpB,qCAAqB,CAAA;IACrB,yCAAyB,CAAA;AAC7B,CAAC,EAHW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAGvB;AAED,MAAa,MAAM;IACR,MAAM,CAAU,WAAW,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC3E,MAAM,CAAU,kBAAkB,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,mBAAmB,CAAC;IAExG,MAAM,CAAC,SAAS,CAAS;IAEjC;;;OAGG;IACI,MAAM,KAAK,QAAQ;QACtB,OAAO,MAAM,CAAC,SAAS,CAAC;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AO,cAAc,CAAC,OAAO,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;IAC7D,CAAC;;AApFL,wBAqFC","file":"common.js","sourcesContent":["const fs = require('fs');\r\nconst fse = require('fs-extra');\r\n\r\n/**\r\n * Error resolution states\r\n */\r\nexport enum ResolveState {\r\n Resolved = 'RESOLVED',\r\n Unresolved = 'UNRESOLVED'\r\n}\r\n\r\nexport class Common {\r\n public static readonly cliRootPath = __dirname.substring(0, __dirname.length - 3);\r\n public static readonly moduleTemplatePath = __dirname.substring(0, __dirname.length - 11) + 'module-template\\\\';\r\n\r\n private static _rootPath: string;\r\n\r\n /**\r\n * Gets the root path for the current repository\r\n * @returns {string} Root path for the current repository\r\n */\r\n public static get rootPath() {\r\n return Common._rootPath;\r\n }\r\n\r\n /**\r\n * Sets the root path for the current repository\r\n * @param {string} path Root path for the current repository\r\n */\r\n public static set rootPath(path) {\r\n Common._rootPath = path;\r\n }\r\n\r\n /**\r\n * Retrieves content of given file\r\n * @param {string} filePath Target file path\r\n * @returns {string | null} String representation of file content or null if file was not found\r\n */\r\n public static readFileData(filePath) {\r\n if (!fs.statSync(filePath).isDirectory()) {\r\n if (!fse.existsSync(filePath)) {\r\n return null;\r\n }\r\n\r\n return fse.readFileSync(filePath, 'utf8');\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Writes to the content of given file\r\n * @param {string} filePath Target file path\r\n * @returns {boolean} indicates whether the file was written successfully.\r\n */\r\n public static writeFileData(filePath, newContent): boolean {\r\n if (!fs.statSync(filePath).isDirectory()) {\r\n if (!fse.existsSync(filePath)) {\r\n return false;\r\n }\r\n\r\n fse.writeFileSync(filePath, newContent, 'utf8');\r\n\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Retrieves content of given JSON file and parses into an object\r\n * @param {string} filePath Target file path\r\n * @returns {any | null} Parsed JSON object or null if file was not found\r\n */\r\n public static readFileJSON(filePath) {\r\n if (!fs.statSync(filePath).isDirectory()) {\r\n if (!fse.existsSync(filePath)) {\r\n return null;\r\n }\r\n\r\n return fse.readJSONSync(filePath);\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Replaces part of target string with a new string using given regex\r\n * @param {string} originalString Target string\r\n * @param {RegExp} regexToReplace Regex to apply to target string\r\n * @param {string} newString String that will replace regex matches\r\n * @returns {string} New string created from replacing regex matches or original string if no matches were found\r\n */\r\n public static replaceInString(originalString, regexToReplace, newString) {\r\n return originalString.replace(regexToReplace, newString);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"sources":["../../../packages/tools/wac-cli/src/common.ts"],"names":[],"mappings":";;;AAAA,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACzB,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEhC;;GAEG;AACH,IAAY,YAGX;AAHD,WAAY,YAAY;IACpB,qCAAqB,CAAA;IACrB,yCAAyB,CAAA;AAC7B,CAAC,EAHW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAGvB;AAED,MAAa,MAAM;IACR,MAAM,CAAU,WAAW,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC3E,MAAM,CAAU,kBAAkB,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,mBAAmB,CAAC;IAExG,MAAM,CAAC,SAAS,CAAS;IAEjC;;;OAGG;IACI,MAAM,KAAK,QAAQ;QACtB,OAAO,MAAM,CAAC,SAAS,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACI,MAAM,KAAK,QAAQ,CAAC,IAAI;QAC3B,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,YAAY,CAAC,QAAQ;QAC/B,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAA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;;;OAMG;IACI,MAAM,CAAC,eAAe,CAAC,cAAc,EAAE,cAAc,EAAE,SAAS;QACnE,OAAO,cAAc,CAAC,OAAO,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;IAC7D,CAAC;;AAlGL,wBAmGC","file":"common.js","sourcesContent":["const fs = require('fs');\r\nconst fse = require('fs-extra');\r\n\r\n/**\r\n * Error resolution states\r\n */\r\nexport enum ResolveState {\r\n Resolved = 'RESOLVED',\r\n Unresolved = 'UNRESOLVED'\r\n}\r\n\r\nexport class Common {\r\n public static readonly cliRootPath = __dirname.substring(0, __dirname.length - 3);\r\n public static readonly moduleTemplatePath = __dirname.substring(0, __dirname.length - 11) + 'module-template\\\\';\r\n\r\n private static _rootPath: string;\r\n\r\n /**\r\n * Gets the root path for the current repository\r\n * @returns {string} Root path for the current repository\r\n */\r\n public static get rootPath() {\r\n return Common._rootPath;\r\n }\r\n\r\n /**\r\n * Sets the root path for the current repository\r\n * @param {string} path Root path for the current repository\r\n */\r\n public static set rootPath(path) {\r\n Common._rootPath = path;\r\n }\r\n\r\n /**\r\n * Retrieves content of given file\r\n * @param {string} filePath Target file path\r\n * @returns {string | null} String representation of file content or null if file was not found\r\n */\r\n public static readFileData(filePath) {\r\n if (!fs.statSync(filePath).isDirectory()) {\r\n if (!fse.existsSync(filePath)) {\r\n return null;\r\n }\r\n\r\n return fse.readFileSync(filePath, 'utf8');\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Writes to the content of given file\r\n * @param {string} filePath Target file path\r\n * @returns {boolean} indicates whether the file was written successfully.\r\n */\r\n public static writeFileData(filePath, newContent): boolean {\r\n if (!fs.statSync(filePath).isDirectory()) {\r\n if (!fse.existsSync(filePath)) {\r\n return false;\r\n }\r\n\r\n fse.writeFileSync(filePath, newContent, 'utf8');\r\n\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Creates the file with content.\r\n * @param {string} filePath Target file path\r\n * @param {string} newContent Content to write to the file\r\n */\r\n public static async writeFile(filePath, newContent): Promise<void> {\r\n await fs.writeFile(filePath, newContent, (err) => {\r\n if (err) {\r\n console.error('Error creating file:', err);\r\n return;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Retrieves content of given JSON file and parses into an object\r\n * @param {string} filePath Target file path\r\n * @returns {any | null} Parsed JSON object or null if file was not found\r\n */\r\n public static readFileJSON(filePath) {\r\n if (!fs.statSync(filePath).isDirectory()) {\r\n if (!fse.existsSync(filePath)) {\r\n return null;\r\n }\r\n\r\n return fse.readJSONSync(filePath);\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Replaces part of target string with a new string using given regex\r\n * @param {string} originalString Target string\r\n * @param {RegExp} regexToReplace Regex to apply to target string\r\n * @param {string} newString String that will replace regex matches\r\n * @returns {string} New string created from replacing regex matches or original string if no matches were found\r\n */\r\n public static replaceInString(originalString, regexToReplace, newString) {\r\n return originalString.replace(regexToReplace, newString);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../packages/tools/wac-cli/src/create/main.ts"],"names":[],"mappings":"AAKA,qBAAa,gBAAgB;IAUb,OAAO,CAAC,IAAI;IATxB;;;;;;;;MAQE;gBACkB,IAAI,EAAE,GAAG;IAEtB,MAAM,IAAI,IAAI;IAyBrB,OAAO,CAAC,YAAY;IAgDpB,OAAO,CAAC,qBAAqB;IA+C7B,OAAO,CAAC,WAAW;IA+EnB,OAAO,CAAC,SAAS;IAgBjB,OAAO,CAAC,qBAAqB;IAgB7B,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,cAAc;CAGzB","file":"main.d.ts","sourcesContent":["import fse from 'fs-extra';\r\nimport { Guid } from 'guid-typescript';\r\nimport pathExists from 'path-exists';\r\nimport { Common } from '../common';\r\n\r\nexport class ExtensionCreator {\r\n /**\r\n * Arguments:\r\n *\t--company - name of the company or person making the extension.\r\n *\t--tool - name of the tool / extension that is being built.\r\n * --solution - name of the solution / extension that is being built.\r\n *\t--version - tag of the version to use.\r\n * --internal - instead of referring to SDK, references point to internal shell library\r\n * @param {any} argv Object containing command arguments\r\n */\r\n constructor(private argv: any) { }\r\n\r\n public create(): void {\r\n const normalizedCompany = this.normalizeString(this.argv.company ? this.argv.company : '');\r\n const normalizedTool = this.normalizeString(this.argv.tool ? this.argv.tool : '');\r\n\r\n const version = this.argv.version ? this.argv.version.toLowerCase() : '';\r\n const extensionType = this.argv.solution ? 'solution' : 'tool';\r\n const normalizedSolution = this.argv.solution ? this.normalizeString(this.argv.solution) : '';\r\n const internal = this.argv.internal;\r\n\r\n if (this.argv.length === 0 || !this.isValidVersion(version) || !normalizedCompany || !normalizedTool) {\r\n console.error('Usage: wac create --company <company-name> --name <tool-name> --version <version-tag> [--verbose]');\r\n console.log('or');\r\n console.log('wac create --company <company-name> --solution <solution-name> --tool <tool-name> --type <tool-type> --version <version-tag> [--verbose]');\r\n console.log('Valid version tags: \\'latest\\', \\'insider\\', \\'next\\', \\'experimental\\'');\r\n console.log('More information can be found here:');\r\n process.exit(1);\r\n }\r\n\r\n if (normalizedSolution === '') {\r\n this.createHelper(extensionType, normalizedCompany, normalizedTool, '', version, internal);\r\n } else {\r\n this.createHelper(extensionType, normalizedCompany, normalizedSolution, normalizedTool, version, internal);\r\n }\r\n }\r\n\r\n private createHelper(\r\n type: string,\r\n company: string,\r\n primaryDisplayName: string,\r\n secondaryDisplayName: string,\r\n version: string,\r\n internal: boolean\r\n ): void {\r\n const ignoresPath = Common.cliRootPath + 'templates\\\\ignores';\r\n const internalPath = Common.cliRootPath + 'templates\\\\internal';\r\n const solutionPath = Common.cliRootPath + 'templates\\\\solution';\r\n const templatePath = Common.cliRootPath + 'templates\\\\wac-template';\r\n const gulpPath = Common.moduleTemplatePath;\r\n\r\n if (pathExists.sync(primaryDisplayName)) {\r\n console.error('This tool definition already exists. No changes have been made.');\r\n } else {\r\n const productPath = './' + primaryDisplayName;\r\n fse.mkdirSync(primaryDisplayName);\r\n console.log('Created ' + productPath);\r\n\r\n fse.copySync(templatePath, productPath);\r\n fse.copySync(gulpPath + '\\\\gulpfile.ts', productPath + '\\\\gulpfile.ts');\r\n fse.copySync(gulpPath + '\\\\build', productPath + '\\\\build');\r\n fse.copyFileSync(gulpPath + '\\\\.eslintrc.json', productPath + '\\\\.eslintrc.json');\r\n fse.copyFileSync(templatePath + '\\\\gulpfile.ts\\\\config-data.ts', productPath + '\\\\gulpfile.ts\\\\config-data.ts');\r\n fse.copyFileSync(ignoresPath + '\\\\git.txt', productPath + '\\\\.gitignore');\r\n fse.copyFileSync(ignoresPath + '\\\\npm.txt', productPath + '\\\\.npmignore');\r\n fse.copyFileSync(ignoresPath + '\\\\browserslistrc.txt', productPath + '\\\\.browserslistrc');\r\n\r\n // For solution extensions, overwrite manifest and strings file\r\n if (type === 'solution') {\r\n fse.copyFileSync(solutionPath + '\\\\manifest.json', productPath + '\\\\src\\\\manifest.json');\r\n fse.copyFileSync(solutionPath + '\\\\strings.resjson', productPath + '\\\\src\\\\resources\\\\strings\\\\strings.resjson');\r\n }\r\n\r\n // For internal developers, overwrite package.json and add .npmrc\r\n if (internal) {\r\n fse.copyFileSync(internalPath + '\\\\package.json', productPath + '\\\\package.json');\r\n fse.copyFileSync(internalPath + '\\\\npmrc.txt', productPath + '\\\\.npmrc');\r\n }\r\n\r\n this.updateShellReferences(primaryDisplayName, internal);\r\n this.updateFiles(company, primaryDisplayName, secondaryDisplayName, version, internal);\r\n this.printOutro(primaryDisplayName);\r\n }\r\n }\r\n\r\n private updateShellReferences(primaryDisplayName: string, internal: boolean): void {\r\n const internalShellReference = '@msft-sme';\r\n const externalShellReference = '@microsoft/windows-admin-center-sdk';\r\n const find = internal ? externalShellReference : internalShellReference;\r\n const replace = internal ? internalShellReference : externalShellReference;\r\n\r\n // For performance reasons, all applicable files are listed here, rather than scanning all files\r\n const extensionDirectory = './' + primaryDisplayName + '/';\r\n const extensionSrcDirectory = extensionDirectory + 'src/';\r\n const extensionAppDirectory = extensionSrcDirectory + 'app/';\r\n const gulpFileDirectory = extensionDirectory + 'gulpfile.ts/';\r\n const gulpFileCommonDirectory = gulpFileDirectory + 'common/';\r\n\r\n const filesWithShellReferences = [\r\n extensionDirectory + 'angular.json',\r\n extensionDirectory + '.eslintrc.json',\r\n gulpFileDirectory + 'config-data.ts',\r\n gulpFileDirectory + 'index.ts',\r\n gulpFileCommonDirectory + 'pack.ts',\r\n gulpFileCommonDirectory + 'powershell.ts',\r\n gulpFileCommonDirectory + 'resjson.ts',\r\n gulpFileCommonDirectory + 'test.ts',\r\n gulpFileCommonDirectory + 'validate.ts',\r\n extensionSrcDirectory + 'main.ts',\r\n extensionSrcDirectory + 'manifest.json',\r\n extensionSrcDirectory + 'polyfills.ts',\r\n extensionSrcDirectory + 'test.ts',\r\n extensionAppDirectory + 'app-routing.module.ts',\r\n extensionAppDirectory + 'app.component.ts',\r\n extensionAppDirectory + 'app.module.ts'\r\n ];\r\n\r\n const cleanFiles = {};\r\n\r\n filesWithShellReferences.forEach((file) => {\r\n cleanFiles[file] = {\r\n [find]: replace\r\n };\r\n });\r\n\r\n for (const key in cleanFiles) {\r\n if (Object.prototype.hasOwnProperty.call(cleanFiles, key)) {\r\n this.cleanFile(key, cleanFiles[key]);\r\n }\r\n }\r\n }\r\n\r\n private updateFiles(\r\n company: string,\r\n primaryDisplayName: string,\r\n secondaryDisplayName: string,\r\n version: string,\r\n internal: boolean\r\n ): void {\r\n /*\r\n / files that need updating:\r\n /\troot package.json\r\n /\tsrc/manifest.json\r\n /\tsrc/resources/strings/strings.resjson\r\n /\tsrc/main.ts\r\n /\tin Experimental: gulpfile.js\r\n */\r\n const cleanDirectory = {};\r\n const rootPackagePath = './' + primaryDisplayName + '/package.json';\r\n const manifestFilePath = './' + primaryDisplayName + '/src/manifest.json';\r\n const mainFilePath = './' + primaryDisplayName + '/src/main.ts';\r\n const stringsFilePath = './' + primaryDisplayName + '/src/resources/strings/strings.resjson';\r\n const gulpFilePath = './' + primaryDisplayName + '/gulpfile.ts/config-data.ts';\r\n\r\n const packageName = '@' + company.toLowerCase() + '/' + primaryDisplayName.toLowerCase();\r\n const manifestName = company.toLowerCase() + '.' + primaryDisplayName.toLowerCase();\r\n const stringsProduct = primaryDisplayName.split('-').join(''); // Strings file cannot handle dashes.\r\n const stringsCompany = company.split('-').join('');\r\n const companyPackageIdentifier = company.split('-').join('') + primaryDisplayName.split('-').join('');\r\n\r\n /*\r\n / Default version is 'latest' in wac-template/package.json\r\n */\r\n if (version === 'next' || version === 'insider' || version === 'experimental') {\r\n const existingVersion = '\"@microsoft/windows-admin-center-sdk\": \"latest\",';\r\n cleanDirectory[rootPackagePath] = {\r\n '@{!company-name}/{!product-name}': packageName,\r\n '\"@microsoft/windows-admin-center-sdk\": \"latest\",': existingVersion.replace('latest', version)\r\n };\r\n } else {\r\n cleanDirectory[rootPackagePath] = { '@{!company-name}/{!product-name}': packageName };\r\n }\r\n\r\n if (!internal) {\r\n this.cleanInternalPackages(rootPackagePath);\r\n }\r\n\r\n cleanDirectory[gulpFilePath] = {\r\n '{!company-name}.{!module-name}': manifestName,\r\n '{!CompanyName}{!ProductName}': stringsCompany + stringsProduct,\r\n '{!guid}': Guid.create(),\r\n '{!company-package-id}': companyPackageIdentifier\r\n };\r\n\r\n cleanDirectory[manifestFilePath] = {\r\n '{!company-name}.{!module-name}': manifestName,\r\n '{!company-name}.{!product-name}': manifestName,\r\n '{!primary-display-name}': primaryDisplayName,\r\n '{!primary-url-name}': primaryDisplayName.toLowerCase(),\r\n '{!secondary-display-name}': secondaryDisplayName,\r\n '{!secondary-url-name}': secondaryDisplayName.toLowerCase()\r\n };\r\n\r\n cleanDirectory[stringsFilePath] = {\r\n '{!product-display-name}': stringsProduct,\r\n '{!product-title}': stringsProduct,\r\n '{!primary-display-name}': primaryDisplayName,\r\n '{!secondary-display-name}': secondaryDisplayName,\r\n '{!ProductName}': stringsProduct,\r\n '{!CompanyName}': stringsCompany\r\n };\r\n\r\n cleanDirectory[mainFilePath] = { '{!company-name}.{!product-name}': manifestName };\r\n\r\n for (const key in cleanDirectory) {\r\n if (Object.prototype.hasOwnProperty.call(cleanDirectory, key)) {\r\n this.cleanFile(key, cleanDirectory[key]);\r\n }\r\n }\r\n }\r\n\r\n private cleanFile(key: string, values: any): void {\r\n console.log('Updating: ' + key);\r\n for (const valuesKey in values) {\r\n if (Object.prototype.hasOwnProperty.call(values, valuesKey)) {\r\n let fileData = fse.readFileSync(key, 'utf8');\r\n let displayNameIndex = fileData.indexOf(valuesKey);\r\n while (displayNameIndex > 0) {\r\n fileData = fileData.replace(valuesKey, values[valuesKey]);\r\n displayNameIndex = fileData.indexOf(valuesKey);\r\n }\r\n\r\n fse.outputFileSync(key, fileData);\r\n }\r\n }\r\n }\r\n\r\n private cleanInternalPackages(packagesFilePath: string): void {\r\n const packages = Common.readFileJSON(packagesFilePath);\r\n const dependencies = [packages.peerDependencies, packages.devDependencies];\r\n\r\n const shellPackageFile = Common.cliRootPath + 'src\\\\config\\\\shell-package-list.json';\r\n const shellPackages = Common.readFileJSON(shellPackageFile).packages;\r\n\r\n dependencies.forEach((target) => {\r\n for (const pack of shellPackages) {\r\n delete target[pack];\r\n }\r\n });\r\n\r\n fse.writeJSONSync(packagesFilePath, packages, { spaces: 2 });\r\n }\r\n\r\n private printOutro(product: string): void {\r\n console.log('');\r\n console.log('Thank you for using the Windows Admin Center CLI.');\r\n console.log('');\r\n console.log('Next steps:');\r\n console.log('cd into your new directory (cd ' + product + ') and then run \\'npm install\\' -> \\'gulp build\\' to build your new extension');\r\n console.log('After that, \\'gulp serve --port 4200\\' to serve your new extension on port 4200');\r\n console.log('Additional information can be found here: https://aka.ms/wacsdkdocs');\r\n }\r\n\r\n private normalizeString(input: string): string {\r\n return input.split(' ').join('-');\r\n }\r\n\r\n private isValidVersion(version: string): boolean {\r\n return version === 'latest' || version === 'next' || version === 'insider' || version === 'release' || version === '' || version === 'experimental';\r\n }\r\n}\r\n"]}
1
+ {"version":3,"sources":["../../../packages/tools/wac-cli/src/create/main.ts"],"names":[],"mappings":"AAMA,qBAAa,gBAAgB;IAUb,OAAO,CAAC,IAAI;IATxB;;;;;;;;MAQE;gBACkB,IAAI,EAAE,GAAG;IAEtB,MAAM,IAAI,IAAI;IAyBrB,OAAO,CAAC,YAAY;IAgDpB,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,WAAW;IA+EnB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,qBAAqB;IAgB7B,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,cAAc;CAGzB","file":"main.d.ts","sourcesContent":["import fse from 'fs-extra';\r\nimport { Guid } from 'guid-typescript';\r\nimport pathExists from 'path-exists';\r\nimport { Common } from '../common';\r\nimport { cleanFile, updateShellReferences } from '../angular15/utils/update-shell-references';\r\n\r\nexport class ExtensionCreator {\r\n /**\r\n * Arguments:\r\n *\t--company - name of the company or person making the extension.\r\n *\t--tool - name of the tool / extension that is being built.\r\n * --solution - name of the solution / extension that is being built.\r\n *\t--version - tag of the version to use.\r\n * --internal - instead of referring to SDK, references point to internal shell library\r\n * @param {any} argv Object containing command arguments\r\n */\r\n constructor(private argv: any) { }\r\n\r\n public create(): void {\r\n const normalizedCompany = this.normalizeString(this.argv.company ? this.argv.company : '');\r\n const normalizedTool = this.normalizeString(this.argv.tool ? this.argv.tool : '');\r\n\r\n const version = this.argv.version ? this.argv.version.toLowerCase() : '';\r\n const extensionType = this.argv.solution ? 'solution' : 'tool';\r\n const normalizedSolution = this.argv.solution ? this.normalizeString(this.argv.solution) : '';\r\n const internal = this.argv.internal;\r\n\r\n if (this.argv.length === 0 || !this.isValidVersion(version) || !normalizedCompany || !normalizedTool) {\r\n console.error('Usage: wac create --company <company-name> --name <tool-name> --version <version-tag> [--verbose]');\r\n console.log('or');\r\n console.log('wac create --company <company-name> --solution <solution-name> --tool <tool-name> --type <tool-type> --version <version-tag> [--verbose]');\r\n console.log('Valid version tags: \\'latest\\', \\'insider\\', \\'next\\', \\'experimental\\'');\r\n console.log('More information can be found here:');\r\n process.exit(1);\r\n }\r\n\r\n if (normalizedSolution === '') {\r\n this.createHelper(extensionType, normalizedCompany, normalizedTool, '', version, internal);\r\n } else {\r\n this.createHelper(extensionType, normalizedCompany, normalizedSolution, normalizedTool, version, internal);\r\n }\r\n }\r\n\r\n private createHelper(\r\n type: string,\r\n company: string,\r\n primaryDisplayName: string,\r\n secondaryDisplayName: string,\r\n version: string,\r\n internal: boolean\r\n ): void {\r\n const ignoresPath = Common.cliRootPath + 'templates\\\\ignores';\r\n const internalPath = Common.cliRootPath + 'templates\\\\internal';\r\n const solutionPath = Common.cliRootPath + 'templates\\\\solution';\r\n const templatePath = Common.cliRootPath + 'templates\\\\wac-template';\r\n const gulpPath = Common.moduleTemplatePath;\r\n\r\n if (pathExists.sync(primaryDisplayName)) {\r\n console.error('This tool definition already exists. No changes have been made.');\r\n } else {\r\n const productPath = './' + primaryDisplayName;\r\n fse.mkdirSync(primaryDisplayName);\r\n console.log('Created ' + productPath);\r\n\r\n fse.copySync(templatePath, productPath);\r\n fse.copySync(gulpPath + '\\\\gulpfile.ts', productPath + '\\\\gulpfile.ts');\r\n fse.copySync(gulpPath + '\\\\build', productPath + '\\\\build');\r\n fse.copyFileSync(gulpPath + '\\\\.eslintrc.json', productPath + '\\\\.eslintrc.json');\r\n fse.copyFileSync(templatePath + '\\\\gulpfile.ts\\\\config-data.ts', productPath + '\\\\gulpfile.ts\\\\config-data.ts');\r\n fse.copyFileSync(ignoresPath + '\\\\git.txt', productPath + '\\\\.gitignore');\r\n fse.copyFileSync(ignoresPath + '\\\\npm.txt', productPath + '\\\\.npmignore');\r\n fse.copyFileSync(ignoresPath + '\\\\browserslistrc.txt', productPath + '\\\\.browserslistrc');\r\n\r\n // For solution extensions, overwrite manifest and strings file\r\n if (type === 'solution') {\r\n fse.copyFileSync(solutionPath + '\\\\manifest.json', productPath + '\\\\src\\\\manifest.json');\r\n fse.copyFileSync(solutionPath + '\\\\strings.resjson', productPath + '\\\\src\\\\resources\\\\strings\\\\strings.resjson');\r\n }\r\n\r\n // For internal developers, overwrite package.json and add .npmrc\r\n if (internal) {\r\n fse.copyFileSync(internalPath + '\\\\package.json', productPath + '\\\\package.json');\r\n fse.copyFileSync(internalPath + '\\\\npmrc.txt', productPath + '\\\\.npmrc');\r\n }\r\n\r\n this.updateShellReferences(primaryDisplayName, internal);\r\n this.updateFiles(company, primaryDisplayName, secondaryDisplayName, version, internal);\r\n this.printOutro(primaryDisplayName);\r\n }\r\n }\r\n\r\n private updateShellReferences(primaryDisplayName: string, internal: boolean): void {\r\n updateShellReferences(primaryDisplayName, internal);\r\n }\r\n\r\n private updateFiles(\r\n company: string,\r\n primaryDisplayName: string,\r\n secondaryDisplayName: string,\r\n version: string,\r\n internal: boolean\r\n ): void {\r\n /*\r\n / files that need updating:\r\n /\troot package.json\r\n /\tsrc/manifest.json\r\n /\tsrc/resources/strings/strings.resjson\r\n /\tsrc/main.ts\r\n /\tin Experimental: gulpfile.js\r\n */\r\n const cleanDirectory = {};\r\n const rootPackagePath = './' + primaryDisplayName + '/package.json';\r\n const manifestFilePath = './' + primaryDisplayName + '/src/manifest.json';\r\n const mainFilePath = './' + primaryDisplayName + '/src/main.ts';\r\n const stringsFilePath = './' + primaryDisplayName + '/src/resources/strings/strings.resjson';\r\n const gulpFilePath = './' + primaryDisplayName + '/gulpfile.ts/config-data.ts';\r\n\r\n const packageName = '@' + company.toLowerCase() + '/' + primaryDisplayName.toLowerCase();\r\n const manifestName = company.toLowerCase() + '.' + primaryDisplayName.toLowerCase();\r\n const stringsProduct = primaryDisplayName.split('-').join(''); // Strings file cannot handle dashes.\r\n const stringsCompany = company.split('-').join('');\r\n const companyPackageIdentifier = company.split('-').join('') + primaryDisplayName.split('-').join('');\r\n\r\n /*\r\n / Default version is 'latest' in wac-template/package.json\r\n */\r\n if (version === 'next' || version === 'insider' || version === 'experimental') {\r\n const existingVersion = '\"@microsoft/windows-admin-center-sdk\": \"latest\",';\r\n cleanDirectory[rootPackagePath] = {\r\n '@{!company-name}/{!product-name}': packageName,\r\n '\"@microsoft/windows-admin-center-sdk\": \"latest\",': existingVersion.replace('latest', version)\r\n };\r\n } else {\r\n cleanDirectory[rootPackagePath] = { '@{!company-name}/{!product-name}': packageName };\r\n }\r\n\r\n if (!internal) {\r\n this.cleanInternalPackages(rootPackagePath);\r\n }\r\n\r\n cleanDirectory[gulpFilePath] = {\r\n '{!company-name}.{!module-name}': manifestName,\r\n '{!CompanyName}{!ProductName}': stringsCompany + stringsProduct,\r\n '{!guid}': Guid.create(),\r\n '{!company-package-id}': companyPackageIdentifier\r\n };\r\n\r\n cleanDirectory[manifestFilePath] = {\r\n '{!company-name}.{!module-name}': manifestName,\r\n '{!company-name}.{!product-name}': manifestName,\r\n '{!primary-display-name}': primaryDisplayName,\r\n '{!primary-url-name}': primaryDisplayName.toLowerCase(),\r\n '{!secondary-display-name}': secondaryDisplayName,\r\n '{!secondary-url-name}': secondaryDisplayName.toLowerCase()\r\n };\r\n\r\n cleanDirectory[stringsFilePath] = {\r\n '{!product-display-name}': stringsProduct,\r\n '{!product-title}': stringsProduct,\r\n '{!primary-display-name}': primaryDisplayName,\r\n '{!secondary-display-name}': secondaryDisplayName,\r\n '{!ProductName}': stringsProduct,\r\n '{!CompanyName}': stringsCompany\r\n };\r\n\r\n cleanDirectory[mainFilePath] = { '{!company-name}.{!product-name}': manifestName };\r\n\r\n for (const key in cleanDirectory) {\r\n if (Object.prototype.hasOwnProperty.call(cleanDirectory, key)) {\r\n this.cleanFile(key, cleanDirectory[key]);\r\n }\r\n }\r\n }\r\n\r\n private cleanFile(key: string, values: any): void {\r\n cleanFile(key, values);\r\n }\r\n\r\n private cleanInternalPackages(packagesFilePath: string): void {\r\n const packages = Common.readFileJSON(packagesFilePath);\r\n const dependencies = [packages.peerDependencies, packages.devDependencies];\r\n\r\n const shellPackageFile = Common.cliRootPath + 'src\\\\config\\\\shell-package-list.json';\r\n const shellPackages = Common.readFileJSON(shellPackageFile).packages;\r\n\r\n dependencies.forEach((target) => {\r\n for (const pack of shellPackages) {\r\n delete target[pack];\r\n }\r\n });\r\n\r\n fse.writeJSONSync(packagesFilePath, packages, { spaces: 2 });\r\n }\r\n\r\n private printOutro(product: string): void {\r\n console.log('');\r\n console.log('Thank you for using the Windows Admin Center CLI.');\r\n console.log('');\r\n console.log('Next steps:');\r\n console.log('cd into your new directory (cd ' + product + ') and then run \\'npm install\\' -> \\'gulp build\\' to build your new extension');\r\n console.log('After that, \\'gulp serve --port 4200\\' to serve your new extension on port 4200');\r\n console.log('Additional information can be found here: https://aka.ms/wacsdkdocs');\r\n }\r\n\r\n private normalizeString(input: string): string {\r\n return input.split(' ').join('-');\r\n }\r\n\r\n private isValidVersion(version: string): boolean {\r\n return version === 'latest' || version === 'next' || version === 'insider' || version === 'release' || version === '' || version === 'experimental';\r\n }\r\n}\r\n"]}
@@ -6,6 +6,7 @@ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
6
6
  const guid_typescript_1 = require("guid-typescript");
7
7
  const path_exists_1 = tslib_1.__importDefault(require("path-exists"));
8
8
  const common_1 = require("../common");
9
+ const update_shell_references_1 = require("../angular15/utils/update-shell-references");
9
10
  class ExtensionCreator {
10
11
  argv;
11
12
  /**
@@ -79,45 +80,7 @@ class ExtensionCreator {
79
80
  }
80
81
  }
81
82
  updateShellReferences(primaryDisplayName, internal) {
82
- const internalShellReference = '@msft-sme';
83
- const externalShellReference = '@microsoft/windows-admin-center-sdk';
84
- const find = internal ? externalShellReference : internalShellReference;
85
- const replace = internal ? internalShellReference : externalShellReference;
86
- // For performance reasons, all applicable files are listed here, rather than scanning all files
87
- const extensionDirectory = './' + primaryDisplayName + '/';
88
- const extensionSrcDirectory = extensionDirectory + 'src/';
89
- const extensionAppDirectory = extensionSrcDirectory + 'app/';
90
- const gulpFileDirectory = extensionDirectory + 'gulpfile.ts/';
91
- const gulpFileCommonDirectory = gulpFileDirectory + 'common/';
92
- const filesWithShellReferences = [
93
- extensionDirectory + 'angular.json',
94
- extensionDirectory + '.eslintrc.json',
95
- gulpFileDirectory + 'config-data.ts',
96
- gulpFileDirectory + 'index.ts',
97
- gulpFileCommonDirectory + 'pack.ts',
98
- gulpFileCommonDirectory + 'powershell.ts',
99
- gulpFileCommonDirectory + 'resjson.ts',
100
- gulpFileCommonDirectory + 'test.ts',
101
- gulpFileCommonDirectory + 'validate.ts',
102
- extensionSrcDirectory + 'main.ts',
103
- extensionSrcDirectory + 'manifest.json',
104
- extensionSrcDirectory + 'polyfills.ts',
105
- extensionSrcDirectory + 'test.ts',
106
- extensionAppDirectory + 'app-routing.module.ts',
107
- extensionAppDirectory + 'app.component.ts',
108
- extensionAppDirectory + 'app.module.ts'
109
- ];
110
- const cleanFiles = {};
111
- filesWithShellReferences.forEach((file) => {
112
- cleanFiles[file] = {
113
- [find]: replace
114
- };
115
- });
116
- for (const key in cleanFiles) {
117
- if (Object.prototype.hasOwnProperty.call(cleanFiles, key)) {
118
- this.cleanFile(key, cleanFiles[key]);
119
- }
120
- }
83
+ (0, update_shell_references_1.updateShellReferences)(primaryDisplayName, internal);
121
84
  }
122
85
  updateFiles(company, primaryDisplayName, secondaryDisplayName, version, internal) {
123
86
  /*
@@ -185,18 +148,7 @@ class ExtensionCreator {
185
148
  }
186
149
  }
187
150
  cleanFile(key, values) {
188
- console.log('Updating: ' + key);
189
- for (const valuesKey in values) {
190
- if (Object.prototype.hasOwnProperty.call(values, valuesKey)) {
191
- let fileData = fs_extra_1.default.readFileSync(key, 'utf8');
192
- let displayNameIndex = fileData.indexOf(valuesKey);
193
- while (displayNameIndex > 0) {
194
- fileData = fileData.replace(valuesKey, values[valuesKey]);
195
- displayNameIndex = fileData.indexOf(valuesKey);
196
- }
197
- fs_extra_1.default.outputFileSync(key, fileData);
198
- }
199
- }
151
+ (0, update_shell_references_1.cleanFile)(key, values);
200
152
  }
201
153
  cleanInternalPackages(packagesFilePath) {
202
154
  const pack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,SAAS,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,EAAE,IAAI,OAAO,KAAK,cAAc,CAAC;IACxJ,CAAC;CACJ;AApQD,4CAoQC","file":"main.js","sourcesContent":["import fse from 'fs-extra';\r\nimport { Guid } from 'guid-typescript';\r\nimport pathExists from 'path-exists';\r\nimport { Common } from '../common';\r\n\r\nexport class ExtensionCreator {\r\n /**\r\n * Arguments:\r\n *\t--company - name of the company or person making the extension.\r\n *\t--tool - name of the tool / extension that is being built.\r\n * --solution - name of the solution / extension that is being built.\r\n *\t--version - tag of the version to use.\r\n * --internal - instead of referring to SDK, references point to internal shell library\r\n * @param {any} argv Object containing command arguments\r\n */\r\n constructor(private argv: any) { }\r\n\r\n public create(): void {\r\n const normalizedCompany = this.normalizeString(this.argv.company ? this.argv.company : '');\r\n const normalizedTool = this.normalizeString(this.argv.tool ? this.argv.tool : '');\r\n\r\n const version = this.argv.version ? this.argv.version.toLowerCase() : '';\r\n const extensionType = this.argv.solution ? 'solution' : 'tool';\r\n const normalizedSolution = this.argv.solution ? this.normalizeString(this.argv.solution) : '';\r\n const internal = this.argv.internal;\r\n\r\n if (this.argv.length === 0 || !this.isValidVersion(version) || !normalizedCompany || !normalizedTool) {\r\n console.error('Usage: wac create --company <company-name> --name <tool-name> --version <version-tag> [--verbose]');\r\n console.log('or');\r\n console.log('wac create --company <company-name> --solution <solution-name> --tool <tool-name> --type <tool-type> --version <version-tag> [--verbose]');\r\n console.log('Valid version tags: \\'latest\\', \\'insider\\', \\'next\\', \\'experimental\\'');\r\n console.log('More information can be found here:');\r\n process.exit(1);\r\n }\r\n\r\n if (normalizedSolution === '') {\r\n this.createHelper(extensionType, normalizedCompany, normalizedTool, '', version, internal);\r\n } else {\r\n this.createHelper(extensionType, normalizedCompany, normalizedSolution, normalizedTool, version, internal);\r\n }\r\n }\r\n\r\n private createHelper(\r\n type: string,\r\n company: string,\r\n primaryDisplayName: string,\r\n secondaryDisplayName: string,\r\n version: string,\r\n internal: boolean\r\n ): void {\r\n const ignoresPath = Common.cliRootPath + 'templates\\\\ignores';\r\n const internalPath = Common.cliRootPath + 'templates\\\\internal';\r\n const solutionPath = Common.cliRootPath + 'templates\\\\solution';\r\n const templatePath = Common.cliRootPath + 'templates\\\\wac-template';\r\n const gulpPath = Common.moduleTemplatePath;\r\n\r\n if (pathExists.sync(primaryDisplayName)) {\r\n console.error('This tool definition already exists. No changes have been made.');\r\n } else {\r\n const productPath = './' + primaryDisplayName;\r\n fse.mkdirSync(primaryDisplayName);\r\n console.log('Created ' + productPath);\r\n\r\n fse.copySync(templatePath, productPath);\r\n fse.copySync(gulpPath + '\\\\gulpfile.ts', productPath + '\\\\gulpfile.ts');\r\n fse.copySync(gulpPath + '\\\\build', productPath + '\\\\build');\r\n fse.copyFileSync(gulpPath + '\\\\.eslintrc.json', productPath + '\\\\.eslintrc.json');\r\n fse.copyFileSync(templatePath + '\\\\gulpfile.ts\\\\config-data.ts', productPath + '\\\\gulpfile.ts\\\\config-data.ts');\r\n fse.copyFileSync(ignoresPath + '\\\\git.txt', productPath + '\\\\.gitignore');\r\n fse.copyFileSync(ignoresPath + '\\\\npm.txt', productPath + '\\\\.npmignore');\r\n fse.copyFileSync(ignoresPath + '\\\\browserslistrc.txt', productPath + '\\\\.browserslistrc');\r\n\r\n // For solution extensions, overwrite manifest and strings file\r\n if (type === 'solution') {\r\n fse.copyFileSync(solutionPath + '\\\\manifest.json', productPath + '\\\\src\\\\manifest.json');\r\n fse.copyFileSync(solutionPath + '\\\\strings.resjson', productPath + '\\\\src\\\\resources\\\\strings\\\\strings.resjson');\r\n }\r\n\r\n // For internal developers, overwrite package.json and add .npmrc\r\n if (internal) {\r\n fse.copyFileSync(internalPath + '\\\\package.json', productPath + '\\\\package.json');\r\n fse.copyFileSync(internalPath + '\\\\npmrc.txt', productPath + '\\\\.npmrc');\r\n }\r\n\r\n this.updateShellReferences(primaryDisplayName, internal);\r\n this.updateFiles(company, primaryDisplayName, secondaryDisplayName, version, internal);\r\n this.printOutro(primaryDisplayName);\r\n }\r\n }\r\n\r\n private updateShellReferences(primaryDisplayName: string, internal: boolean): void {\r\n const internalShellReference = '@msft-sme';\r\n const externalShellReference = '@microsoft/windows-admin-center-sdk';\r\n const find = internal ? externalShellReference : internalShellReference;\r\n const replace = internal ? internalShellReference : externalShellReference;\r\n\r\n // For performance reasons, all applicable files are listed here, rather than scanning all files\r\n const extensionDirectory = './' + primaryDisplayName + '/';\r\n const extensionSrcDirectory = extensionDirectory + 'src/';\r\n const extensionAppDirectory = extensionSrcDirectory + 'app/';\r\n const gulpFileDirectory = extensionDirectory + 'gulpfile.ts/';\r\n const gulpFileCommonDirectory = gulpFileDirectory + 'common/';\r\n\r\n const filesWithShellReferences = [\r\n extensionDirectory + 'angular.json',\r\n extensionDirectory + '.eslintrc.json',\r\n gulpFileDirectory + 'config-data.ts',\r\n gulpFileDirectory + 'index.ts',\r\n gulpFileCommonDirectory + 'pack.ts',\r\n gulpFileCommonDirectory + 'powershell.ts',\r\n gulpFileCommonDirectory + 'resjson.ts',\r\n gulpFileCommonDirectory + 'test.ts',\r\n gulpFileCommonDirectory + 'validate.ts',\r\n extensionSrcDirectory + 'main.ts',\r\n extensionSrcDirectory + 'manifest.json',\r\n extensionSrcDirectory + 'polyfills.ts',\r\n extensionSrcDirectory + 'test.ts',\r\n extensionAppDirectory + 'app-routing.module.ts',\r\n extensionAppDirectory + 'app.component.ts',\r\n extensionAppDirectory + 'app.module.ts'\r\n ];\r\n\r\n const cleanFiles = {};\r\n\r\n filesWithShellReferences.forEach((file) => {\r\n cleanFiles[file] = {\r\n [find]: replace\r\n };\r\n });\r\n\r\n for (const key in cleanFiles) {\r\n if (Object.prototype.hasOwnProperty.call(cleanFiles, key)) {\r\n this.cleanFile(key, cleanFiles[key]);\r\n }\r\n }\r\n }\r\n\r\n private updateFiles(\r\n company: string,\r\n primaryDisplayName: string,\r\n secondaryDisplayName: string,\r\n version: string,\r\n internal: boolean\r\n ): void {\r\n /*\r\n / files that need updating:\r\n /\troot package.json\r\n /\tsrc/manifest.json\r\n /\tsrc/resources/strings/strings.resjson\r\n /\tsrc/main.ts\r\n /\tin Experimental: gulpfile.js\r\n */\r\n const cleanDirectory = {};\r\n const rootPackagePath = './' + primaryDisplayName + '/package.json';\r\n const manifestFilePath = './' + primaryDisplayName + '/src/manifest.json';\r\n const mainFilePath = './' + primaryDisplayName + '/src/main.ts';\r\n const stringsFilePath = './' + primaryDisplayName + '/src/resources/strings/strings.resjson';\r\n const gulpFilePath = './' + primaryDisplayName + '/gulpfile.ts/config-data.ts';\r\n\r\n const packageName = '@' + company.toLowerCase() + '/' + primaryDisplayName.toLowerCase();\r\n const manifestName = company.toLowerCase() + '.' + primaryDisplayName.toLowerCase();\r\n const stringsProduct = primaryDisplayName.split('-').join(''); // Strings file cannot handle dashes.\r\n const stringsCompany = company.split('-').join('');\r\n const companyPackageIdentifier = company.split('-').join('') + primaryDisplayName.split('-').join('');\r\n\r\n /*\r\n / Default version is 'latest' in wac-template/package.json\r\n */\r\n if (version === 'next' || version === 'insider' || version === 'experimental') {\r\n const existingVersion = '\"@microsoft/windows-admin-center-sdk\": \"latest\",';\r\n cleanDirectory[rootPackagePath] = {\r\n '@{!company-name}/{!product-name}': packageName,\r\n '\"@microsoft/windows-admin-center-sdk\": \"latest\",': existingVersion.replace('latest', version)\r\n };\r\n } else {\r\n cleanDirectory[rootPackagePath] = { '@{!company-name}/{!product-name}': packageName };\r\n }\r\n\r\n if (!internal) {\r\n this.cleanInternalPackages(rootPackagePath);\r\n }\r\n\r\n cleanDirectory[gulpFilePath] = {\r\n '{!company-name}.{!module-name}': manifestName,\r\n '{!CompanyName}{!ProductName}': stringsCompany + stringsProduct,\r\n '{!guid}': Guid.create(),\r\n '{!company-package-id}': companyPackageIdentifier\r\n };\r\n\r\n cleanDirectory[manifestFilePath] = {\r\n '{!company-name}.{!module-name}': manifestName,\r\n '{!company-name}.{!product-name}': manifestName,\r\n '{!primary-display-name}': primaryDisplayName,\r\n '{!primary-url-name}': primaryDisplayName.toLowerCase(),\r\n '{!secondary-display-name}': secondaryDisplayName,\r\n '{!secondary-url-name}': secondaryDisplayName.toLowerCase()\r\n };\r\n\r\n cleanDirectory[stringsFilePath] = {\r\n '{!product-display-name}': stringsProduct,\r\n '{!product-title}': stringsProduct,\r\n '{!primary-display-name}': primaryDisplayName,\r\n '{!secondary-display-name}': secondaryDisplayName,\r\n '{!ProductName}': stringsProduct,\r\n '{!CompanyName}': stringsCompany\r\n };\r\n\r\n cleanDirectory[mainFilePath] = { '{!company-name}.{!product-name}': manifestName };\r\n\r\n for (const key in cleanDirectory) {\r\n if (Object.prototype.hasOwnProperty.call(cleanDirectory, key)) {\r\n this.cleanFile(key, cleanDirectory[key]);\r\n }\r\n }\r\n }\r\n\r\n private cleanFile(key: string, values: any): void {\r\n console.log('Updating: ' + key);\r\n for (const valuesKey in values) {\r\n if (Object.prototype.hasOwnProperty.call(values, valuesKey)) {\r\n let fileData = fse.readFileSync(key, 'utf8');\r\n let displayNameIndex = fileData.indexOf(valuesKey);\r\n while (displayNameIndex > 0) {\r\n fileData = fileData.replace(valuesKey, values[valuesKey]);\r\n displayNameIndex = fileData.indexOf(valuesKey);\r\n }\r\n\r\n fse.outputFileSync(key, fileData);\r\n }\r\n }\r\n }\r\n\r\n private cleanInternalPackages(packagesFilePath: string): void {\r\n const packages = Common.readFileJSON(packagesFilePath);\r\n const dependencies = [packages.peerDependencies, packages.devDependencies];\r\n\r\n const shellPackageFile = Common.cliRootPath + 'src\\\\config\\\\shell-package-list.json';\r\n const shellPackages = Common.readFileJSON(shellPackageFile).packages;\r\n\r\n dependencies.forEach((target) => {\r\n for (const pack of shellPackages) {\r\n delete target[pack];\r\n }\r\n });\r\n\r\n fse.writeJSONSync(packagesFilePath, packages, { spaces: 2 });\r\n }\r\n\r\n private printOutro(product: string): void {\r\n console.log('');\r\n console.log('Thank you for using the Windows Admin Center CLI.');\r\n console.log('');\r\n console.log('Next steps:');\r\n console.log('cd into your new directory (cd ' + product + ') and then run \\'npm install\\' -> \\'gulp build\\' to build your new extension');\r\n console.log('After that, \\'gulp serve --port 4200\\' to serve your new extension on port 4200');\r\n console.log('Additional information can be found here: https://aka.ms/wacsdkdocs');\r\n }\r\n\r\n private normalizeString(input: string): string {\r\n return input.split(' ').join('-');\r\n }\r\n\r\n private isValidVersion(version: string): boolean {\r\n return version === 'latest' || version === 'next' || version === 'insider' || version === 'release' || version === '' || version === 'experimental';\r\n }\r\n}\r\n"]}
1
+ {"version":3,"sources":["../../../packages/tools/wac-cli/src/create/main.ts"],"names":[],"mappings":";;;;AAAA,gEAA2B;AAC3B,qDAAuC;AACvC,sEAAqC;AACrC,sCAAmC;AACnC,wFAA8F;AAE9F,MAAa,gBAAgB;IAUL;IATpB;;;;;;;;MAQE;IACF,YAAoB,IAAS;QAAT,SAAI,GAAJ,IAAI,CAAK;IAAI,CAAC;IAE3B,MAAM;QACT,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC3F,MAAM,cAAc,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAElF,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzE,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC;QAC/D,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,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C;aACvB;QACL,CAAC,CAAC,CAAC;QAEH,kBAAG,CAAC,aAAa,CAAC,gBAAgB,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IACjE,CAAC;IAEO,UAAU,CAAC,OAAe;QAC9B,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;QACjE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,iCAAiC,GAAG,OAAO,GAAG,8EAA8E,CAAC,CAAC;QAC1I,OAAO,CAAC,GAAG,CAAC,iFAAiF,CAAC,CAAC;QAC/F,OAAO,CAAC,GAAG,CAAC,qEAAqE,CAAC,CAAC;IACvF,CAAC;IAEO,eAAe,CAAC,KAAa;QACjC,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;IAEO,cAAc,CAAC,OAAe;QAClC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,EAAE,IAAI,OAAO,KAAK,cAAc,CAAC;IACxJ,CAAC;CACJ;AA7MD,4CA6MC","file":"main.js","sourcesContent":["import fse from 'fs-extra';\r\nimport { Guid } from 'guid-typescript';\r\nimport pathExists from 'path-exists';\r\nimport { Common } from '../common';\r\nimport { cleanFile, updateShellReferences } from '../angular15/utils/update-shell-references';\r\n\r\nexport class ExtensionCreator {\r\n /**\r\n * Arguments:\r\n *\t--company - name of the company or person making the extension.\r\n *\t--tool - name of the tool / extension that is being built.\r\n * --solution - name of the solution / extension that is being built.\r\n *\t--version - tag of the version to use.\r\n * --internal - instead of referring to SDK, references point to internal shell library\r\n * @param {any} argv Object containing command arguments\r\n */\r\n constructor(private argv: any) { }\r\n\r\n public create(): void {\r\n const normalizedCompany = this.normalizeString(this.argv.company ? this.argv.company : '');\r\n const normalizedTool = this.normalizeString(this.argv.tool ? this.argv.tool : '');\r\n\r\n const version = this.argv.version ? this.argv.version.toLowerCase() : '';\r\n const extensionType = this.argv.solution ? 'solution' : 'tool';\r\n const normalizedSolution = this.argv.solution ? this.normalizeString(this.argv.solution) : '';\r\n const internal = this.argv.internal;\r\n\r\n if (this.argv.length === 0 || !this.isValidVersion(version) || !normalizedCompany || !normalizedTool) {\r\n console.error('Usage: wac create --company <company-name> --name <tool-name> --version <version-tag> [--verbose]');\r\n console.log('or');\r\n console.log('wac create --company <company-name> --solution <solution-name> --tool <tool-name> --type <tool-type> --version <version-tag> [--verbose]');\r\n console.log('Valid version tags: \\'latest\\', \\'insider\\', \\'next\\', \\'experimental\\'');\r\n console.log('More information can be found here:');\r\n process.exit(1);\r\n }\r\n\r\n if (normalizedSolution === '') {\r\n this.createHelper(extensionType, normalizedCompany, normalizedTool, '', version, internal);\r\n } else {\r\n this.createHelper(extensionType, normalizedCompany, normalizedSolution, normalizedTool, version, internal);\r\n }\r\n }\r\n\r\n private createHelper(\r\n type: string,\r\n company: string,\r\n primaryDisplayName: string,\r\n secondaryDisplayName: string,\r\n version: string,\r\n internal: boolean\r\n ): void {\r\n const ignoresPath = Common.cliRootPath + 'templates\\\\ignores';\r\n const internalPath = Common.cliRootPath + 'templates\\\\internal';\r\n const solutionPath = Common.cliRootPath + 'templates\\\\solution';\r\n const templatePath = Common.cliRootPath + 'templates\\\\wac-template';\r\n const gulpPath = Common.moduleTemplatePath;\r\n\r\n if (pathExists.sync(primaryDisplayName)) {\r\n console.error('This tool definition already exists. No changes have been made.');\r\n } else {\r\n const productPath = './' + primaryDisplayName;\r\n fse.mkdirSync(primaryDisplayName);\r\n console.log('Created ' + productPath);\r\n\r\n fse.copySync(templatePath, productPath);\r\n fse.copySync(gulpPath + '\\\\gulpfile.ts', productPath + '\\\\gulpfile.ts');\r\n fse.copySync(gulpPath + '\\\\build', productPath + '\\\\build');\r\n fse.copyFileSync(gulpPath + '\\\\.eslintrc.json', productPath + '\\\\.eslintrc.json');\r\n fse.copyFileSync(templatePath + '\\\\gulpfile.ts\\\\config-data.ts', productPath + '\\\\gulpfile.ts\\\\config-data.ts');\r\n fse.copyFileSync(ignoresPath + '\\\\git.txt', productPath + '\\\\.gitignore');\r\n fse.copyFileSync(ignoresPath + '\\\\npm.txt', productPath + '\\\\.npmignore');\r\n fse.copyFileSync(ignoresPath + '\\\\browserslistrc.txt', productPath + '\\\\.browserslistrc');\r\n\r\n // For solution extensions, overwrite manifest and strings file\r\n if (type === 'solution') {\r\n fse.copyFileSync(solutionPath + '\\\\manifest.json', productPath + '\\\\src\\\\manifest.json');\r\n fse.copyFileSync(solutionPath + '\\\\strings.resjson', productPath + '\\\\src\\\\resources\\\\strings\\\\strings.resjson');\r\n }\r\n\r\n // For internal developers, overwrite package.json and add .npmrc\r\n if (internal) {\r\n fse.copyFileSync(internalPath + '\\\\package.json', productPath + '\\\\package.json');\r\n fse.copyFileSync(internalPath + '\\\\npmrc.txt', productPath + '\\\\.npmrc');\r\n }\r\n\r\n this.updateShellReferences(primaryDisplayName, internal);\r\n this.updateFiles(company, primaryDisplayName, secondaryDisplayName, version, internal);\r\n this.printOutro(primaryDisplayName);\r\n }\r\n }\r\n\r\n private updateShellReferences(primaryDisplayName: string, internal: boolean): void {\r\n updateShellReferences(primaryDisplayName, internal);\r\n }\r\n\r\n private updateFiles(\r\n company: string,\r\n primaryDisplayName: string,\r\n secondaryDisplayName: string,\r\n version: string,\r\n internal: boolean\r\n ): void {\r\n /*\r\n / files that need updating:\r\n /\troot package.json\r\n /\tsrc/manifest.json\r\n /\tsrc/resources/strings/strings.resjson\r\n /\tsrc/main.ts\r\n /\tin Experimental: gulpfile.js\r\n */\r\n const cleanDirectory = {};\r\n const rootPackagePath = './' + primaryDisplayName + '/package.json';\r\n const manifestFilePath = './' + primaryDisplayName + '/src/manifest.json';\r\n const mainFilePath = './' + primaryDisplayName + '/src/main.ts';\r\n const stringsFilePath = './' + primaryDisplayName + '/src/resources/strings/strings.resjson';\r\n const gulpFilePath = './' + primaryDisplayName + '/gulpfile.ts/config-data.ts';\r\n\r\n const packageName = '@' + company.toLowerCase() + '/' + primaryDisplayName.toLowerCase();\r\n const manifestName = company.toLowerCase() + '.' + primaryDisplayName.toLowerCase();\r\n const stringsProduct = primaryDisplayName.split('-').join(''); // Strings file cannot handle dashes.\r\n const stringsCompany = company.split('-').join('');\r\n const companyPackageIdentifier = company.split('-').join('') + primaryDisplayName.split('-').join('');\r\n\r\n /*\r\n / Default version is 'latest' in wac-template/package.json\r\n */\r\n if (version === 'next' || version === 'insider' || version === 'experimental') {\r\n const existingVersion = '\"@microsoft/windows-admin-center-sdk\": \"latest\",';\r\n cleanDirectory[rootPackagePath] = {\r\n '@{!company-name}/{!product-name}': packageName,\r\n '\"@microsoft/windows-admin-center-sdk\": \"latest\",': existingVersion.replace('latest', version)\r\n };\r\n } else {\r\n cleanDirectory[rootPackagePath] = { '@{!company-name}/{!product-name}': packageName };\r\n }\r\n\r\n if (!internal) {\r\n this.cleanInternalPackages(rootPackagePath);\r\n }\r\n\r\n cleanDirectory[gulpFilePath] = {\r\n '{!company-name}.{!module-name}': manifestName,\r\n '{!CompanyName}{!ProductName}': stringsCompany + stringsProduct,\r\n '{!guid}': Guid.create(),\r\n '{!company-package-id}': companyPackageIdentifier\r\n };\r\n\r\n cleanDirectory[manifestFilePath] = {\r\n '{!company-name}.{!module-name}': manifestName,\r\n '{!company-name}.{!product-name}': manifestName,\r\n '{!primary-display-name}': primaryDisplayName,\r\n '{!primary-url-name}': primaryDisplayName.toLowerCase(),\r\n '{!secondary-display-name}': secondaryDisplayName,\r\n '{!secondary-url-name}': secondaryDisplayName.toLowerCase()\r\n };\r\n\r\n cleanDirectory[stringsFilePath] = {\r\n '{!product-display-name}': stringsProduct,\r\n '{!product-title}': stringsProduct,\r\n '{!primary-display-name}': primaryDisplayName,\r\n '{!secondary-display-name}': secondaryDisplayName,\r\n '{!ProductName}': stringsProduct,\r\n '{!CompanyName}': stringsCompany\r\n };\r\n\r\n cleanDirectory[mainFilePath] = { '{!company-name}.{!product-name}': manifestName };\r\n\r\n for (const key in cleanDirectory) {\r\n if (Object.prototype.hasOwnProperty.call(cleanDirectory, key)) {\r\n this.cleanFile(key, cleanDirectory[key]);\r\n }\r\n }\r\n }\r\n\r\n private cleanFile(key: string, values: any): void {\r\n cleanFile(key, values);\r\n }\r\n\r\n private cleanInternalPackages(packagesFilePath: string): void {\r\n const packages = Common.readFileJSON(packagesFilePath);\r\n const dependencies = [packages.peerDependencies, packages.devDependencies];\r\n\r\n const shellPackageFile = Common.cliRootPath + 'src\\\\config\\\\shell-package-list.json';\r\n const shellPackages = Common.readFileJSON(shellPackageFile).packages;\r\n\r\n dependencies.forEach((target) => {\r\n for (const pack of shellPackages) {\r\n delete target[pack];\r\n }\r\n });\r\n\r\n fse.writeJSONSync(packagesFilePath, packages, { spaces: 2 });\r\n }\r\n\r\n private printOutro(product: string): void {\r\n console.log('');\r\n console.log('Thank you for using the Windows Admin Center CLI.');\r\n console.log('');\r\n console.log('Next steps:');\r\n console.log('cd into your new directory (cd ' + product + ') and then run \\'npm install\\' -> \\'gulp build\\' to build your new extension');\r\n console.log('After that, \\'gulp serve --port 4200\\' to serve your new extension on port 4200');\r\n console.log('Additional information can be found here: https://aka.ms/wacsdkdocs');\r\n }\r\n\r\n private normalizeString(input: string): string {\r\n return input.split(' ').join('-');\r\n }\r\n\r\n private isValidVersion(version: string): boolean {\r\n return version === 'latest' || version === 'next' || version === 'insider' || version === 'release' || version === '' || version === 'experimental';\r\n }\r\n}\r\n"]}
@@ -66,7 +66,10 @@ export declare class EslintUpgrader {
66
66
  private addEslintSchematics;
67
67
  private esLintSchematicsRunModuleApp;
68
68
  private esLintSchematicsRunModuleLib;
69
- private replaceEslintConfig;
69
+ /**
70
+ * It updates to the eslintrc.json file on the root of the project.
71
+ */
72
+ replaceEslintConfig(): Promise<void>;
70
73
  private uninstallDependencies;
71
74
  private installDependencies;
72
75
  private fixEslintErrors;
@@ -76,4 +79,5 @@ export declare class EslintUpgrader {
76
79
  private cleanUpKarmaConfigFile;
77
80
  private runCommand;
78
81
  private logger;
82
+ private sleep;
79
83
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../packages/tools/wac-cli/src/eslint/main.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,oBAAY,WAAW;IACnB,cAAc,mBAAmB;IACjC,iBAAiB,sBAAsB;IACvC,WAAW,gBAAgB;CAC9B;AAED;;GAEG;AACH,oBAAY,sBAAsB;IAC9B,eAAe,0CAA0C;IACzD,iBAAiB,2BAA2B;IAC5C,wBAAwB,+BAA+B;IACvD,2BAA2B,kCAAkC;IAC7D,qBAAqB,4BAA4B;IACjD,qBAAqB,yCAAyC;IAC9D,iBAAiB,6EAA6E;IAC9F,mBAAmB,kCAAkC;IACrD,qBAAqB,sCAAsC;IAC3D,qBAAqB,uCAAuC;IAC5D,kBAAkB,gEAAgE;IAClF,kBAAkB,gEAAgE;IAClF,kBAAkB,uCAAuC;IACzD,eAAe,qCAAqC;IACpD,eAAe,sCAAsC;IACrD,mBAAmB,yMAIlB;IACD,SAAS,uBAAuB;CACnC;AAED;;;GAGG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,eAAe,CAAS;IAEhC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAwB;IAC7D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;IACpD,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAA+B;IAC1E,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;IAElD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAoB;IACzD,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAEtC;IACF,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAwB;IAC1D,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAyB;IAC7D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAmB;IACjD,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAqC;IAC5E,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAA4B;IACxE,OAAO,CAAC,QAAQ,CAAC,sCAAsC,CAAmD;IAE1G;;;;OAIG;IACU,OAAO,CAAC,KAAK,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;;IAwElD,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,kBAAkB;YAOZ,mBAAmB;YAOnB,4BAA4B;YAO5B,4BAA4B;YAO5B,mBAAmB;YAQnB,qBAAqB;YAcrB,mBAAmB;YASnB,eAAe;YAUf,mBAAmB;YA4BnB,SAAS;IAMvB,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,sBAAsB;IAS9B,OAAO,CAAC,UAAU;IAmClB,OAAO,CAAC,MAAM;CAGjB","file":"main.d.ts","sourcesContent":["import fse, { pathExists } from 'fs-extra';\r\nimport { Common } from '../common';\r\nimport { exec } from 'child_process';\r\n\r\n/**\r\n * Represents the type of upgrade that needs to be performed.\r\n */\r\nexport enum UpgradeType {\r\n WithBaseConfig = 'WithBaseConfig',\r\n WithoutBaseConfig = 'WithoutBaseConfig',\r\n NoOperation = 'NoOperation'\r\n}\r\n\r\n/**\r\n * Represents the messages that are displayed during the upgrade process.\r\n */\r\nexport enum EslintUpgraderMessages {\r\n StartingUpgrade = 'Starting upgrade eslinting process...',\r\n CheckingFilePaths = 'Checking file paths...',\r\n UpdateTypeWithBaseConfig = 'UpdateType: WithBaseConfig',\r\n UpdateTypeWithoutBaseConfig = 'UpdateType: WithoutBaseConfig',\r\n UpdateTypeWithoutBoth = 'UpdateType: NoOperation',\r\n ExitWithoutBaseConfig = 'Exiting upgrade eslinting process...',\r\n RCANoTsConfigFile = 'Please manually create a tsconfig.json file in the root of your project.',\r\n GettingTsConfigFile = 'Getting tsconfig.json file...',\r\n UpdateTsConfigContent = 'Updating tsconfig.json content...',\r\n RevertTsConfigContent = 'Reverting tsconfig.json content...',\r\n RenameTsBaseConfig = 'Renaming tsconfig.base.json to tsconfig.base.json_backup...',\r\n RevertTsBaseConfig = 'Renaming tsconfig.base.json_backup to tsconfig.base.json...',\r\n UpdateEslintConfig = 'Updating .eslintrc.json content...',\r\n UpdatePolyfills = 'Updating polyfills.ts content...',\r\n UpdateKarmaFile = 'Updating karma.conf.js content...',\r\n FinalizeInfoLintFix = `There are eslint violations that needs fix... After fixing the violations, please run the following commands:\\n\r\n npx eslint . --fix \\n\r\n gulp lintApp \\n\r\n gulp build \\n\r\n `,\r\n Completed = 'Upgrade completed!'\r\n}\r\n\r\n/**\r\n * This is the main class of the EslintUpgrader tool.\r\n * It is responsible for upgrading the Tslint to Eslint.\r\n */\r\nexport class EslintUpgrader {\r\n private tsconfigBaseFilePath: string;\r\n private tsconfigFilePath: string;\r\n private angularFilePath: string;\r\n\r\n private debug = false;\r\n private libUpgrade = false;\r\n\r\n private readonly tsconfigBaseFileName = 'tsconfig.base.json';\r\n private readonly tsconfigFileName = 'tsconfig.json';\r\n private readonly tsconfigBaseFileNameBackUp = 'tsconfig.base.json_backup';\r\n private readonly angularFileName = 'angular.json';\r\n\r\n private readonly eslintConfigFileName = '.eslintrc.json';\r\n private readonly eslintConfigFileContent = {\r\n \"extends\": \"./node_modules/@microsoft/windows-admin-center-sdk/tools/code-formatter/.eslintrc.base.json\"\r\n };\r\n private readonly polifillsFilePath = './src/polyfills.ts';\r\n private readonly karmaConfigFilePath = './src/karma.conf.js';\r\n private readonly eslintDisable = 'eslint-disable'\r\n private readonly targetGulpLintFilePath = '.\\\\gulpfile.ts\\\\common\\\\lint.ts';\r\n private readonly targetGulpLintIndexFilePath = './gulpfile.ts/index.ts';\r\n private readonly targetGulpLintUiTestAutomationFilePath = '.\\\\gulpfile.ts\\\\common\\\\ui-test-automation.ts';\r\n\r\n /**\r\n * The main upgrade process\r\n * @param debug - Indicates if the debug mode is enabled.\r\n * @returns Promise<void> - Returns a promise that resolves when the upgrade process is completed.\r\n */\r\n public async upgrade(debug = false): Promise<void> {\r\n this.debug = !!debug;\r\n\r\n this.logger(EslintUpgraderMessages.StartingUpgrade);\r\n this.logger(EslintUpgraderMessages.CheckingFilePaths);\r\n\r\n const upgradeType = this.checkFileExists();\r\n this.checkLibUpgrade();\r\n\r\n switch (upgradeType) {\r\n case UpgradeType.WithBaseConfig:\r\n this.logger(EslintUpgraderMessages.UpdateTypeWithBaseConfig);\r\n\r\n this.updateTsConfigContent();\r\n this.renameTsBaseConfig();\r\n await this.addEslintSchematics();\r\n await this.esLintSchematicsRunModuleApp();\r\n\r\n if (this.libUpgrade) {\r\n await this.esLintSchematicsRunModuleLib();\r\n }\r\n\r\n await this.uninstallDependencies();\r\n await this.installDependencies();\r\n await this.replaceEslintConfig();\r\n this.updateTsConfigContent(true);\r\n this.renameTsBaseConfig(true);\r\n await this.replaceGulpLintFile();\r\n this.cleanUpPolyfills();\r\n this.cleanUpKarmaConfigFile();\r\n await this.fixEslintErrors();\r\n await this.gulpBuild();\r\n\r\n break;\r\n case UpgradeType.WithoutBaseConfig:\r\n this.logger(EslintUpgraderMessages.UpdateTypeWithoutBaseConfig);\r\n\r\n await this.addEslintSchematics();\r\n await this.esLintSchematicsRunModuleApp();\r\n\r\n if (this.libUpgrade) {\r\n await this.esLintSchematicsRunModuleLib();\r\n }\r\n\r\n await this.uninstallDependencies();\r\n await this.installDependencies();\r\n await this.replaceEslintConfig();\r\n await this.replaceGulpLintFile();\r\n this.cleanUpPolyfills();\r\n this.cleanUpKarmaConfigFile();\r\n await this.fixEslintErrors();\r\n await this.gulpBuild();\r\n\r\n break;\r\n case UpgradeType.NoOperation:\r\n this.logger(EslintUpgraderMessages.UpdateTypeWithoutBoth);\r\n this.logger(EslintUpgraderMessages.ExitWithoutBaseConfig);\r\n this.logger(EslintUpgraderMessages.RCANoTsConfigFile);\r\n\r\n break;\r\n default:\r\n break;\r\n }\r\n\r\n this.logger(EslintUpgraderMessages.Completed);\r\n }\r\n\r\n constructor() {\r\n Common.rootPath = process.cwd();\r\n this.updateBasicPaths();\r\n }\r\n\r\n private updateBasicPaths(): void {\r\n this.tsconfigBaseFilePath = Common.rootPath + '\\\\' + this.tsconfigBaseFileName;\r\n this.tsconfigFilePath = Common.rootPath + '\\\\' + this.tsconfigFileName;\r\n this.angularFilePath = Common.rootPath + '\\\\' + this.angularFileName;\r\n }\r\n\r\n private checkLibUpgrade(): void {\r\n const angularFilePathExists = pathExists(this.angularFilePath);\r\n if (!angularFilePathExists) {\r\n return;\r\n }\r\n\r\n const angularFileContent = Common.readFileData(this.angularFilePath);\r\n this.libUpgrade = !!angularFileContent.includes('module-lib');\r\n }\r\n\r\n private checkFileExists(): UpgradeType {\r\n const tsconfigBaseFilePathExists = pathExists(this.tsconfigBaseFilePath);\r\n const tsconfigFilePathExists = pathExists(this.tsconfigFilePath);\r\n if (tsconfigBaseFilePathExists && tsconfigFilePathExists) {\r\n return UpgradeType.WithBaseConfig;\r\n } else if (tsconfigFilePathExists) {\r\n return UpgradeType.WithoutBaseConfig;\r\n } else {\r\n return UpgradeType.NoOperation;\r\n }\r\n }\r\n\r\n private updateTsConfigContent(revert = false) {\r\n revert ? this.logger(EslintUpgraderMessages.RevertTsConfigContent) : this.logger(EslintUpgraderMessages.UpdateTsConfigContent);\r\n\r\n revert ?\r\n this.updateFile(this.tsconfigFilePath, `// \"extends\": \"./${this.tsconfigBaseFileName}\"`, `\"extends\": \"./${this.tsconfigBaseFileName}\"`) :\r\n this.updateFile(this.tsconfigFilePath, `\"extends\": \"./${this.tsconfigBaseFileName}\"`, `// \"extends\": \"./${this.tsconfigBaseFileName}\"`);\r\n }\r\n\r\n private updateFile(filePath: string, prev: string, target: string): void {\r\n this.logger('Updating file...' + filePath + ',' + prev + ',' + target + '...');\r\n\r\n let fileData = Common.readFileData(filePath);\r\n fileData = fileData.replace(prev, target);\r\n fse.writeFileSync(filePath, fileData);\r\n }\r\n\r\n private renameTsBaseConfig(revert = false): void {\r\n revert ? this.logger(EslintUpgraderMessages.RenameTsBaseConfig) : this.logger(EslintUpgraderMessages.RevertTsBaseConfig);\r\n\r\n const cmd = revert ? `git mv ./${this.tsconfigBaseFileNameBackUp} ./${this.tsconfigBaseFileName}` : `git mv ./${this.tsconfigBaseFileName} ./${this.tsconfigBaseFileNameBackUp}`;\r\n this.runCommand(cmd);\r\n }\r\n\r\n private async addEslintSchematics(): Promise<void> {\r\n const cmd = 'ng add @angular-eslint/schematics';\r\n\r\n this.logger(cmd);\r\n await this.runCommand(cmd);\r\n }\r\n\r\n private async esLintSchematicsRunModuleApp(): Promise<void> {\r\n const cmd = 'ng g @angular-eslint/schematics:convert-tslint-to-eslint module-app';\r\n\r\n this.logger(cmd);\r\n await this.runCommand(cmd);\r\n }\r\n\r\n private async esLintSchematicsRunModuleLib(): Promise<void> {\r\n const cmd = 'ng g @angular-eslint/schematics:convert-tslint-to-eslint module-lib';\r\n\r\n this.logger(cmd);\r\n await this.runCommand(cmd);\r\n }\r\n\r\n private async replaceEslintConfig(): Promise<void> {\r\n const formattedNewContent = JSON.stringify(this.eslintConfigFileContent, null, 2)\r\n .replace('}', '}\\n')\r\n\r\n this.logger(EslintUpgraderMessages.UpdateEslintConfig);\r\n Common.writeFileData(`./${this.eslintConfigFileName}`, formattedNewContent);\r\n }\r\n\r\n private async uninstallDependencies(): Promise<void> {\r\n const cmd = 'npm uninstall codelyzer gulp-tslint rxjs-tslint rxjs-tslint-rules tslint tslint-consistent-codestyle tslint-eslint-rules tslint-microsoft-contrib';\r\n\r\n this.logger(cmd);\r\n await this.runCommand(cmd);\r\n\r\n const removeForRollBackCmd = 'npm uninstall gulp-eslint eslint eslint-plugin-angular eslint-plugin-import eslint-plugin-jsdoc eslint-plugin-jsonc eslint-plugin-prefer-arrow ' +\r\n '@typescript-eslint/eslint-plugin @typescript-eslint/parser @angular-eslint/builder @angular-eslint/eslint-plugin @angular-eslint/eslint-plugin-template @angular-eslint/schematics ' +\r\n '@angular-eslint/template-parser'\r\n\r\n this.logger(removeForRollBackCmd);\r\n await this.runCommand(removeForRollBackCmd);\r\n }\r\n\r\n private async installDependencies(): Promise<void> {\r\n const cmd = 'npm install gulp-eslint@6.0.0 eslint@7.6.0 eslint-plugin-angular@4.1.0 eslint-plugin-import@2.21.0 eslint-plugin-jsdoc@36.1.1 eslint-plugin-jsonc@2.8.0 eslint-plugin-prefer-arrow@1.2.3 ' +\r\n '@typescript-eslint/eslint-plugin@4.16.1 @typescript-eslint/parser@4.16.1 @angular-eslint/builder@4.3.1 @angular-eslint/eslint-plugin@4.3.1 @angular-eslint/eslint-plugin-template@4.3.1 ' +\r\n '@angular-eslint/schematics@4.3.1 @angular-eslint/template-parser@4.3.1 --save-dev';\r\n\r\n this.logger(cmd);\r\n await this.runCommand(cmd);\r\n }\r\n\r\n private async fixEslintErrors(): Promise<void> {\r\n const rootFileLinterFix = 'npx eslint . --fix';\r\n this.logger(rootFileLinterFix);\r\n await this.runCommand(rootFileLinterFix, true, EslintUpgraderMessages.FinalizeInfoLintFix);\r\n\r\n const projectLinterFix = 'npx ng lint --fix';\r\n this.logger(projectLinterFix);\r\n await this.runCommand(projectLinterFix, true, EslintUpgraderMessages.FinalizeInfoLintFix);\r\n }\r\n\r\n private async replaceGulpLintFile(): Promise<void> {\r\n const cmd = `del ${this.targetGulpLintFilePath}`;\r\n\r\n this.logger(cmd);\r\n await this.runCommand(cmd);\r\n\r\n if (pathExists(this.targetGulpLintIndexFilePath)) {\r\n this.updateFile(\r\n this.targetGulpLintIndexFilePath,\r\n `import { LintModule } from './common/lint'`,\r\n `import { LintModule } from '../node_modules/@microsoft/windows-admin-center-sdk/tools/code-formatter/lint'`);\r\n }\r\n\r\n if (pathExists(this.targetGulpLintUiTestAutomationFilePath)) {\r\n this.updateFile(\r\n this.targetGulpLintUiTestAutomationFilePath,\r\n `import { LintModule } from './lint'`,\r\n `import { LintModule } from '../../node_modules/@microsoft/windows-admin-center-sdk/tools/code-formatter/lint'`);\r\n\r\n // The new UI automation framework will remove this line.\r\n // This is for the repositories that has not yet onboraded to the new frawework.\r\n this.updateFile(\r\n this.targetGulpLintUiTestAutomationFilePath,\r\n `export const uiTestAutomation = series(LintModule.lintUiTestAutomation, buildUiTestAutomation);`,\r\n `export const uiTestAutomation = series(LintModule.lintUiTestAutomation_legacy, buildUiTestAutomation);`);\r\n }\r\n }\r\n\r\n private async gulpBuild(): Promise<void> {\r\n const cmd = 'gulp build';\r\n this.logger(cmd);\r\n await this.runCommand(cmd);\r\n }\r\n\r\n private cleanUpPolyfills(): void {\r\n this.logger(EslintUpgraderMessages.UpdatePolyfills);\r\n\r\n const fileDataInLines = Common.readFileData(this.polifillsFilePath).split('\\n');\r\n const newLines = fileDataInLines.filter(line => !line.includes(this.eslintDisable));\r\n Common.writeFileData(this.polifillsFilePath, newLines.join('\\n'));\r\n }\r\n\r\n private cleanUpKarmaConfigFile(): void {\r\n this.logger(EslintUpgraderMessages.UpdateKarmaFile);\r\n\r\n this.updateFile(\r\n this.karmaConfigFilePath,\r\n `module.exports = (config) => {`,\r\n `module.exports = function (config) {`);\r\n }\r\n\r\n private runCommand(cmd: string, forceDebug = false, finalizeInfo = undefined): Promise<void> {\r\n console.log(`Running ${cmd}`);\r\n return new Promise((resolve) => {\r\n const child = exec(cmd, (error, stdout, stderr) => {\r\n if (error) {\r\n console.error(` exec error: ${error}`);\r\n return;\r\n }\r\n\r\n stdout.split('\\n').filter(line => line.trimEnd()).forEach(line => console.log(line));\r\n stderr.split('\\n').filter(line => line.trimEnd()).forEach(line => console.error(line));\r\n\r\n resolve();\r\n });\r\n\r\n if (this.debug || forceDebug) {\r\n child.stdout.on('data', (data) => {\r\n data.split('\\n').filter(line => line.trimEnd()).forEach(line => console.log(` ${line}`));\r\n });\r\n }\r\n\r\n child.stderr.on('data', (data) => {\r\n data.split('\\n').filter(line => line.trimEnd()).forEach(line => console.error(` ${line}`));\r\n });\r\n\r\n child.on('close', (code) => {\r\n console.log(`exitCode: ${code}`);\r\n if (code !== 0 && finalizeInfo) {\r\n this.logger(finalizeInfo);\r\n this.logger(EslintUpgraderMessages.Completed);\r\n }\r\n });\r\n });\r\n }\r\n\r\n private logger(value: EslintUpgraderMessages | string, prefix = 'Main thread') {\r\n console.log(`${prefix} - ${value}`);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"sources":["../../../packages/tools/wac-cli/src/eslint/main.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,oBAAY,WAAW;IACnB,cAAc,mBAAmB;IACjC,iBAAiB,sBAAsB;IACvC,WAAW,gBAAgB;CAC9B;AAED;;GAEG;AACH,oBAAY,sBAAsB;IAC9B,eAAe,0CAA0C;IACzD,iBAAiB,2BAA2B;IAC5C,wBAAwB,+BAA+B;IACvD,2BAA2B,kCAAkC;IAC7D,qBAAqB,4BAA4B;IACjD,qBAAqB,yCAAyC;IAC9D,iBAAiB,6EAA6E;IAC9F,mBAAmB,kCAAkC;IACrD,qBAAqB,sCAAsC;IAC3D,qBAAqB,uCAAuC;IAC5D,kBAAkB,gEAAgE;IAClF,kBAAkB,gEAAgE;IAClF,kBAAkB,uCAAuC;IACzD,eAAe,qCAAqC;IACpD,eAAe,sCAAsC;IACrD,mBAAmB,yMAIlB;IACD,SAAS,uBAAuB;CACnC;AAED;;;GAGG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,eAAe,CAAS;IAEhC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CA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* Represents the type of upgrade that needs to be performed.\r\n */\r\nexport enum UpgradeType {\r\n WithBaseConfig = 'WithBaseConfig',\r\n WithoutBaseConfig = 'WithoutBaseConfig',\r\n NoOperation = 'NoOperation'\r\n}\r\n\r\n/**\r\n * Represents the messages that are displayed during the upgrade process.\r\n */\r\nexport enum EslintUpgraderMessages {\r\n StartingUpgrade = 'Starting upgrade eslinting process...',\r\n CheckingFilePaths = 'Checking file paths...',\r\n UpdateTypeWithBaseConfig = 'UpdateType: WithBaseConfig',\r\n UpdateTypeWithoutBaseConfig = 'UpdateType: WithoutBaseConfig',\r\n UpdateTypeWithoutBoth = 'UpdateType: NoOperation',\r\n ExitWithoutBaseConfig = 'Exiting upgrade eslinting process...',\r\n RCANoTsConfigFile = 'Please manually create a tsconfig.json file in the root of your project.',\r\n GettingTsConfigFile = 'Getting tsconfig.json file...',\r\n UpdateTsConfigContent = 'Updating tsconfig.json content...',\r\n RevertTsConfigContent = 'Reverting tsconfig.json content...',\r\n RenameTsBaseConfig = 'Renaming tsconfig.base.json to tsconfig.base.json_backup...',\r\n RevertTsBaseConfig = 'Renaming tsconfig.base.json_backup to tsconfig.base.json...',\r\n UpdateEslintConfig = 'Updating .eslintrc.json content...',\r\n UpdatePolyfills = 'Updating polyfills.ts content...',\r\n UpdateKarmaFile = 'Updating karma.conf.js content...',\r\n FinalizeInfoLintFix = `There are eslint violations that needs fix... After fixing the violations, please run the following commands:\\n\r\n npx eslint . --fix \\n\r\n gulp lintApp \\n\r\n gulp build \\n\r\n `,\r\n Completed = 'Upgrade completed!'\r\n}\r\n\r\n/**\r\n * This is the main class of the EslintUpgrader tool.\r\n * It is responsible for upgrading the Tslint to Eslint.\r\n */\r\nexport class EslintUpgrader {\r\n private tsconfigBaseFilePath: string;\r\n private tsconfigFilePath: string;\r\n private angularFilePath: string;\r\n\r\n private debug = false;\r\n private libUpgrade = false;\r\n\r\n private readonly tsconfigBaseFileName = 'tsconfig.base.json';\r\n private readonly tsconfigFileName = 'tsconfig.json';\r\n private readonly tsconfigBaseFileNameBackUp = 'tsconfig.base.json_backup';\r\n private readonly angularFileName = 'angular.json';\r\n\r\n private readonly eslintConfigFileName = '.eslintrc.json';\r\n private readonly eslintConfigFileContent = {\r\n \"extends\": \"./node_modules/@microsoft/windows-admin-center-sdk/tools/code-formatter/.eslintrc.base.json\"\r\n };\r\n private readonly polifillsFilePath = './src/polyfills.ts';\r\n private readonly karmaConfigFilePath = './src/karma.conf.js';\r\n private readonly eslintDisable = 'eslint-disable'\r\n private readonly targetGulpLintFilePath = '.\\\\gulpfile.ts\\\\common\\\\lint.ts';\r\n private readonly targetGulpLintIndexFilePath = './gulpfile.ts/index.ts';\r\n private readonly targetGulpLintUiTestAutomationFilePath = '.\\\\gulpfile.ts\\\\common\\\\ui-test-automation.ts';\r\n\r\n /**\r\n * The main upgrade process\r\n * @param debug - Indicates if the debug mode is enabled.\r\n * @returns Promise<void> - Returns a promise that resolves when the upgrade process is completed.\r\n */\r\n public async upgrade(debug = false): Promise<void> {\r\n this.debug = !!debug;\r\n\r\n this.logger(EslintUpgraderMessages.StartingUpgrade);\r\n this.logger(EslintUpgraderMessages.CheckingFilePaths);\r\n\r\n const upgradeType = this.checkFileExists();\r\n this.checkLibUpgrade();\r\n\r\n switch (upgradeType) {\r\n case UpgradeType.WithBaseConfig:\r\n this.logger(EslintUpgraderMessages.UpdateTypeWithBaseConfig);\r\n\r\n this.updateTsConfigContent();\r\n this.renameTsBaseConfig();\r\n await this.addEslintSchematics();\r\n await this.esLintSchematicsRunModuleApp();\r\n\r\n if (this.libUpgrade) {\r\n await this.esLintSchematicsRunModuleLib();\r\n }\r\n\r\n await this.uninstallDependencies();\r\n await this.installDependencies();\r\n await this.replaceEslintConfig();\r\n this.updateTsConfigContent(true);\r\n this.renameTsBaseConfig(true);\r\n await this.replaceGulpLintFile();\r\n this.cleanUpPolyfills();\r\n this.cleanUpKarmaConfigFile();\r\n await this.fixEslintErrors();\r\n await this.gulpBuild();\r\n\r\n break;\r\n case UpgradeType.WithoutBaseConfig:\r\n this.logger(EslintUpgraderMessages.UpdateTypeWithoutBaseConfig);\r\n\r\n await this.addEslintSchematics();\r\n await this.esLintSchematicsRunModuleApp();\r\n\r\n if (this.libUpgrade) {\r\n await this.esLintSchematicsRunModuleLib();\r\n }\r\n\r\n await this.uninstallDependencies();\r\n await this.installDependencies();\r\n await this.replaceEslintConfig();\r\n await this.replaceGulpLintFile();\r\n this.cleanUpPolyfills();\r\n this.cleanUpKarmaConfigFile();\r\n await this.fixEslintErrors();\r\n await this.gulpBuild();\r\n\r\n break;\r\n case UpgradeType.NoOperation:\r\n this.logger(EslintUpgraderMessages.UpdateTypeWithoutBoth);\r\n this.logger(EslintUpgraderMessages.ExitWithoutBaseConfig);\r\n this.logger(EslintUpgraderMessages.RCANoTsConfigFile);\r\n\r\n break;\r\n default:\r\n break;\r\n }\r\n\r\n this.logger(EslintUpgraderMessages.Completed);\r\n }\r\n\r\n constructor() {\r\n Common.rootPath = process.cwd();\r\n this.updateBasicPaths();\r\n }\r\n\r\n private updateBasicPaths(): void {\r\n this.tsconfigBaseFilePath = Common.rootPath + '\\\\' + this.tsconfigBaseFileName;\r\n this.tsconfigFilePath = Common.rootPath + '\\\\' + this.tsconfigFileName;\r\n this.angularFilePath = Common.rootPath + '\\\\' + this.angularFileName;\r\n }\r\n\r\n private checkLibUpgrade(): void {\r\n const angularFilePathExists = pathExists(this.angularFilePath);\r\n if (!angularFilePathExists) {\r\n return;\r\n }\r\n\r\n const angularFileContent = Common.readFileData(this.angularFilePath);\r\n this.libUpgrade = !!angularFileContent.includes('module-lib');\r\n }\r\n\r\n private checkFileExists(): UpgradeType {\r\n const tsconfigBaseFilePathExists = pathExists(this.tsconfigBaseFilePath);\r\n const tsconfigFilePathExists = pathExists(this.tsconfigFilePath);\r\n if (tsconfigBaseFilePathExists && tsconfigFilePathExists) {\r\n return UpgradeType.WithBaseConfig;\r\n } else if (tsconfigFilePathExists) {\r\n return UpgradeType.WithoutBaseConfig;\r\n } else {\r\n return UpgradeType.NoOperation;\r\n }\r\n }\r\n\r\n private updateTsConfigContent(revert = false) {\r\n revert ? this.logger(EslintUpgraderMessages.RevertTsConfigContent) : this.logger(EslintUpgraderMessages.UpdateTsConfigContent);\r\n\r\n revert ?\r\n this.updateFile(this.tsconfigFilePath, `// \"extends\": \"./${this.tsconfigBaseFileName}\"`, `\"extends\": \"./${this.tsconfigBaseFileName}\"`) :\r\n this.updateFile(this.tsconfigFilePath, `\"extends\": \"./${this.tsconfigBaseFileName}\"`, `// \"extends\": \"./${this.tsconfigBaseFileName}\"`);\r\n }\r\n\r\n private updateFile(filePath: string, prev: string, target: string): void {\r\n this.logger('Updating file...' + filePath + ',' + prev + ',' + target + '...');\r\n\r\n let fileData = Common.readFileData(filePath);\r\n fileData = fileData.replace(prev, target);\r\n fse.writeFileSync(filePath, fileData);\r\n }\r\n\r\n private renameTsBaseConfig(revert = false): void {\r\n revert ? this.logger(EslintUpgraderMessages.RenameTsBaseConfig) : this.logger(EslintUpgraderMessages.RevertTsBaseConfig);\r\n\r\n const cmd = revert ? `git mv ./${this.tsconfigBaseFileNameBackUp} ./${this.tsconfigBaseFileName}` : `git mv ./${this.tsconfigBaseFileName} ./${this.tsconfigBaseFileNameBackUp}`;\r\n this.runCommand(cmd);\r\n }\r\n\r\n private async addEslintSchematics(): Promise<void> {\r\n const cmd = 'ng add @angular-eslint/schematics --skip-confirmation';\r\n\r\n this.logger(cmd);\r\n await this.runCommand(cmd);\r\n }\r\n\r\n private async esLintSchematicsRunModuleApp(): Promise<void> {\r\n const cmd = 'ng g @angular-eslint/schematics:convert-tslint-to-eslint module-app';\r\n\r\n this.logger(cmd);\r\n await this.runCommand(cmd);\r\n }\r\n\r\n private async esLintSchematicsRunModuleLib(): Promise<void> {\r\n const cmd = 'ng g @angular-eslint/schematics:convert-tslint-to-eslint module-lib';\r\n\r\n this.logger(cmd);\r\n await this.runCommand(cmd);\r\n }\r\n\r\n /**\r\n * It updates to the eslintrc.json file on the root of the project.\r\n */\r\n public async replaceEslintConfig(): Promise<void> {\r\n const formattedNewContent = JSON.stringify(this.eslintConfigFileContent, null, 2)\r\n .replace('}', '}\\n')\r\n\r\n this.logger(EslintUpgraderMessages.UpdateEslintConfig);\r\n\r\n if (fse.existsSync(`./${this.eslintConfigFileName}`)) {\r\n this.logger('Updating eslint file');\r\n Common.writeFileData(`./${this.eslintConfigFileName}`, formattedNewContent);\r\n } else {\r\n this.logger('Creating new eslint file');\r\n Common.writeFile(`./${this.eslintConfigFileName}`, formattedNewContent);\r\n }\r\n\r\n // race condition for the eslintrc file not being released by the writeFile function.\r\n await this.sleep(1000);\r\n }\r\n\r\n private async uninstallDependencies(): Promise<void> {\r\n const cmd = 'npm uninstall codelyzer gulp-tslint rxjs-tslint rxjs-tslint-rules tslint tslint-consistent-codestyle tslint-eslint-rules tslint-microsoft-contrib';\r\n\r\n this.logger(cmd);\r\n await this.runCommand(cmd);\r\n\r\n const removeForRollBackCmd = 'npm uninstall gulp-eslint eslint eslint-plugin-angular eslint-plugin-import eslint-plugin-jsdoc eslint-plugin-jsonc eslint-plugin-prefer-arrow ' +\r\n '@typescript-eslint/eslint-plugin @typescript-eslint/parser @angular-eslint/builder @angular-eslint/eslint-plugin @angular-eslint/eslint-plugin-template @angular-eslint/schematics ' +\r\n '@angular-eslint/template-parser'\r\n\r\n this.logger(removeForRollBackCmd);\r\n await this.runCommand(removeForRollBackCmd);\r\n }\r\n\r\n private async installDependencies(): Promise<void> {\r\n const cmd = 'npm install gulp-eslint@6.0.0 eslint@7.6.0 eslint-plugin-angular@4.1.0 eslint-plugin-import@2.21.0 eslint-plugin-jsdoc@36.1.1 eslint-plugin-jsonc@2.8.0 eslint-plugin-prefer-arrow@1.2.3 ' +\r\n '@typescript-eslint/eslint-plugin@4.16.1 @typescript-eslint/parser@4.16.1 @angular-eslint/builder@4.3.1 @angular-eslint/eslint-plugin@4.3.1 @angular-eslint/eslint-plugin-template@4.3.1 ' +\r\n '@angular-eslint/schematics@4.3.1 @angular-eslint/template-parser@4.3.1 --save-dev';\r\n\r\n this.logger(cmd);\r\n await this.runCommand(cmd);\r\n }\r\n\r\n private async fixEslintErrors(): Promise<void> {\r\n const rootFileLinterFix = 'npx eslint . --fix';\r\n this.logger(rootFileLinterFix);\r\n await this.runCommand(rootFileLinterFix, true, EslintUpgraderMessages.FinalizeInfoLintFix);\r\n\r\n const projectLinterFix = 'npx ng lint --fix';\r\n this.logger(projectLinterFix);\r\n await this.runCommand(projectLinterFix, true, EslintUpgraderMessages.FinalizeInfoLintFix);\r\n }\r\n\r\n private async replaceGulpLintFile(): Promise<void> {\r\n const cmd = `del ${this.targetGulpLintFilePath}`;\r\n\r\n this.logger(cmd);\r\n await this.runCommand(cmd);\r\n\r\n if (pathExists(this.targetGulpLintIndexFilePath)) {\r\n this.updateFile(\r\n this.targetGulpLintIndexFilePath,\r\n `import { LintModule } from './common/lint'`,\r\n `import { LintModule } from '../node_modules/@microsoft/windows-admin-center-sdk/tools/code-formatter/lint'`);\r\n }\r\n\r\n if (pathExists(this.targetGulpLintUiTestAutomationFilePath)) {\r\n this.updateFile(\r\n this.targetGulpLintUiTestAutomationFilePath,\r\n `import { LintModule } from './lint'`,\r\n `import { LintModule } from '../../node_modules/@microsoft/windows-admin-center-sdk/tools/code-formatter/lint'`);\r\n\r\n // The new UI automation framework will remove this line.\r\n // This is for the repositories that has not yet onboraded to the new frawework.\r\n this.updateFile(\r\n this.targetGulpLintUiTestAutomationFilePath,\r\n `export const uiTestAutomation = series(LintModule.lintUiTestAutomation, buildUiTestAutomation);`,\r\n `export const uiTestAutomation = series(LintModule.lintUiTestAutomation_legacy, buildUiTestAutomation);`);\r\n }\r\n }\r\n\r\n private async gulpBuild(): Promise<void> {\r\n const cmd = 'gulp build';\r\n this.logger(cmd);\r\n await this.runCommand(cmd);\r\n }\r\n\r\n private cleanUpPolyfills(): void {\r\n this.logger(EslintUpgraderMessages.UpdatePolyfills);\r\n\r\n const fileDataInLines = Common.readFileData(this.polifillsFilePath).split('\\n');\r\n const newLines = fileDataInLines.filter(line => !line.includes(this.eslintDisable));\r\n Common.writeFileData(this.polifillsFilePath, newLines.join('\\n'));\r\n }\r\n\r\n private cleanUpKarmaConfigFile(): void {\r\n this.logger(EslintUpgraderMessages.UpdateKarmaFile);\r\n\r\n this.updateFile(\r\n this.karmaConfigFilePath,\r\n `module.exports = (config) => {`,\r\n `module.exports = function (config) {`);\r\n }\r\n\r\n private runCommand(cmd: string, forceDebug = false, finalizeInfo = undefined): Promise<void> {\r\n console.log(`Running ${cmd}`);\r\n return new Promise((resolve) => {\r\n const child = exec(cmd, (error, stdout, stderr) => {\r\n if (error) {\r\n console.error(` exec error: ${error}`);\r\n return;\r\n }\r\n\r\n stdout.split('\\n').filter(line => line.trimEnd()).forEach(line => console.log(line));\r\n stderr.split('\\n').filter(line => line.trimEnd()).forEach(line => console.error(line));\r\n\r\n resolve();\r\n });\r\n\r\n if (this.debug || forceDebug) {\r\n child.stdout.on('data', (data) => {\r\n data.split('\\n').filter(line => line.trimEnd()).forEach(line => console.log(` ${line}`));\r\n });\r\n }\r\n\r\n child.stderr.on('data', (data) => {\r\n data.split('\\n').filter(line => line.trimEnd()).forEach(line => console.error(` ${line}`));\r\n });\r\n\r\n child.on('close', (code) => {\r\n console.log(`exitCode: ${code}`);\r\n if (code !== 0 && finalizeInfo) {\r\n this.logger(finalizeInfo);\r\n this.logger(EslintUpgraderMessages.Completed);\r\n }\r\n });\r\n });\r\n }\r\n\r\n private logger(value: EslintUpgraderMessages | string, prefix = 'Main thread') {\r\n console.log(`${prefix} - ${value}`);\r\n }\r\n\r\n private sleep(ms: number): Promise<void> {\r\n return new Promise(resolve => setTimeout(resolve, ms));\r\n }\r\n}\r\n"]}
@@ -167,7 +167,7 @@ class EslintUpgrader {
167
167
  this.runCommand(cmd);
168
168
  }
169
169
  async addEslintSchematics() {
170
- const cmd = 'ng add @angular-eslint/schematics';
170
+ const cmd = 'ng add @angular-eslint/schematics --skip-confirmation';
171
171
  this.logger(cmd);
172
172
  await this.runCommand(cmd);
173
173
  }
@@ -181,11 +181,23 @@ class EslintUpgrader {
181
181
  this.logger(cmd);
182
182
  await this.runCommand(cmd);
183
183
  }
184
+ /**
185
+ * It updates to the eslintrc.json file on the root of the project.
186
+ */
184
187
  async replaceEslintConfig() {
185
188
  const formattedNewContent = JSON.stringify(this.eslintConfigFileContent, null, 2)
186
189
  .replace('}', '}\n');
187
190
  this.logger(EslintUpgraderMessages.UpdateEslintConfig);
188
- common_1.Common.writeFileData(`./${this.eslintConfigFileName}`, formattedNewContent);
191
+ if (fs_extra_1.default.existsSync(`./${this.eslintConfigFileName}`)) {
192
+ this.logger('Updating eslint file');
193
+ common_1.Common.writeFileData(`./${this.eslintConfigFileName}`, formattedNewContent);
194
+ }
195
+ else {
196
+ this.logger('Creating new eslint file');
197
+ common_1.Common.writeFile(`./${this.eslintConfigFileName}`, formattedNewContent);
198
+ }
199
+ // race condition for the eslintrc file not being released by the writeFile function.
200
+ await this.sleep(1000);
189
201
  }
190
202
  async uninstallDependencies() {
191
203
  const cmd = 'npm uninstall codelyzer gulp-tslint rxjs-tslint rxjs-tslint-rules tslint tslint-consistent-codestyle tslint-eslint-rules tslint-microsoft-contrib';
@@ -273,6 +285,9 @@ class EslintUpgrader {
273
285
  logger(value, prefix = 'Main thread') {
274
286
  console.log(`${prefix} - ${value}`);
275
287
  }
288
+ sleep(ms) {
289
+ return new Promise(resolve => setTimeout(resolve, ms));
290
+ }
276
291
  }
277
292
  exports.EslintUpgrader = EslintUpgrader;
278
293