@sap-ux/adp-tooling 0.9.28 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from './types';
2
2
  export * from './preview/adp-preview';
3
- export { generate } from './writer';
3
+ export { generate, migrate } from './writer';
4
4
  export { generateChange } from './writer/editors';
5
5
  export { promptGeneratorInput, PromptDefaults } from './base/prompt';
6
6
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -14,11 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.promptGeneratorInput = exports.generateChange = exports.generate = void 0;
17
+ exports.promptGeneratorInput = exports.generateChange = exports.migrate = exports.generate = void 0;
18
18
  __exportStar(require("./types"), exports);
19
19
  __exportStar(require("./preview/adp-preview"), exports);
20
20
  var writer_1 = require("./writer");
21
21
  Object.defineProperty(exports, "generate", { enumerable: true, get: function () { return writer_1.generate; } });
22
+ Object.defineProperty(exports, "migrate", { enumerable: true, get: function () { return writer_1.migrate; } });
22
23
  var editors_1 = require("./writer/editors");
23
24
  Object.defineProperty(exports, "generateChange", { enumerable: true, get: function () { return editors_1.generateChange; } });
24
25
  var prompt_1 = require("./base/prompt");
@@ -9,4 +9,13 @@ import type { AdpWriterConfig } from '../types';
9
9
  * @returns the updated memfs editor instance
10
10
  */
11
11
  export declare function generate(basePath: string, config: AdpWriterConfig, fs?: Editor): Promise<Editor>;
12
+ /**
13
+ * Writes the adp-project template to the mem-fs-editor instance during migration.
14
+ *
15
+ * @param basePath - the base path
16
+ * @param config - the writer configuration
17
+ * @param fs - the memfs editor instance
18
+ * @returns the updated memfs editor instance
19
+ */
20
+ export declare function migrate(basePath: string, config: AdpWriterConfig, fs?: Editor): Promise<Editor>;
12
21
  //# sourceMappingURL=index.d.ts.map
@@ -9,12 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.generate = void 0;
12
+ exports.migrate = exports.generate = void 0;
13
13
  const path_1 = require("path");
14
14
  const mem_fs_1 = require("mem-fs");
15
15
  const mem_fs_editor_1 = require("mem-fs-editor");
16
16
  const ui5_config_1 = require("@sap-ux/ui5-config");
17
17
  const options_1 = require("./options");
18
+ const tmplPath = (0, path_1.join)(__dirname, '../../templates/project');
18
19
  /**
19
20
  * Set default values for optional properties.
20
21
  *
@@ -38,6 +39,22 @@ function setDefaults(config) {
38
39
  (_e = (_j = configWithDefaults.package).description) !== null && _e !== void 0 ? _e : (_j.description = configWithDefaults.app.title);
39
40
  return configWithDefaults;
40
41
  }
42
+ function writeUi5Yaml(basePath, config, fs) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ // ui5.yaml
45
+ const ui5ConfigPath = (0, path_1.join)(basePath, 'ui5.yaml');
46
+ const baseUi5ConfigContent = fs.read(ui5ConfigPath);
47
+ const ui5Config = yield ui5_config_1.UI5Config.newInstance(baseUi5ConfigContent);
48
+ (0, options_1.enhanceUI5Yaml)(ui5Config, config);
49
+ fs.write(ui5ConfigPath, ui5Config.toString());
50
+ // ui5-deploy.yaml
51
+ if ((0, options_1.hasDeployConfig)(config)) {
52
+ const ui5DeployConfig = yield ui5_config_1.UI5Config.newInstance(baseUi5ConfigContent);
53
+ (0, options_1.enhanceUI5DeployYaml)(ui5DeployConfig, config);
54
+ fs.write((0, path_1.join)(basePath, 'ui5-deploy.yaml'), ui5DeployConfig.toString());
55
+ }
56
+ });
57
+ }
41
58
  /**
42
59
  * Writes the adp-project template to the mem-fs-editor instance.
43
60
  *
@@ -51,26 +68,46 @@ function generate(basePath, config, fs) {
51
68
  if (!fs) {
52
69
  fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
53
70
  }
54
- const tmplPath = (0, path_1.join)(__dirname, '../../templates/project');
55
71
  const fullConfig = setDefaults(config);
56
72
  fs.copyTpl((0, path_1.join)(tmplPath, '**/*.*'), (0, path_1.join)(basePath), fullConfig, undefined, {
57
73
  globOptions: { dot: true },
58
74
  processDestinationPath: (filePath) => filePath.replace(/gitignore.tmpl/g, '.gitignore')
59
75
  });
60
- // ui5.yaml
61
- const ui5ConfigPath = (0, path_1.join)(basePath, 'ui5.yaml');
62
- const baseUi5ConfigContent = fs.read(ui5ConfigPath);
63
- const ui5Config = yield ui5_config_1.UI5Config.newInstance(baseUi5ConfigContent);
64
- (0, options_1.enhanceUI5Yaml)(ui5Config, fullConfig);
65
- fs.write(ui5ConfigPath, ui5Config.toString());
66
- // ui5-deploy.yaml
67
- if ((0, options_1.hasDeployConfig)(fullConfig)) {
68
- const ui5DeployConfig = yield ui5_config_1.UI5Config.newInstance(baseUi5ConfigContent);
69
- (0, options_1.enhanceUI5DeployYaml)(ui5DeployConfig, fullConfig);
70
- fs.write((0, path_1.join)(basePath, 'ui5-deploy.yaml'), ui5DeployConfig.toString());
71
- }
76
+ yield writeUi5Yaml(basePath, fullConfig, fs);
72
77
  return fs;
73
78
  });
74
79
  }
75
80
  exports.generate = generate;
81
+ /**
82
+ * Writes the adp-project template to the mem-fs-editor instance during migration.
83
+ *
84
+ * @param basePath - the base path
85
+ * @param config - the writer configuration
86
+ * @param fs - the memfs editor instance
87
+ * @returns the updated memfs editor instance
88
+ */
89
+ function migrate(basePath, config, fs) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ if (!fs) {
92
+ fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
93
+ }
94
+ const fullConfig = setDefaults(config);
95
+ // copy all files except app discriptor
96
+ fs.copyTpl((0, path_1.join)(tmplPath, '**/*.*'), (0, path_1.join)(basePath), fullConfig, undefined, {
97
+ globOptions: { dot: true, ignore: ['manifest.appdescr_variant'] },
98
+ processDestinationPath: (filePath) => filePath.replace(/gitignore.tmpl/g, '.gitignore')
99
+ });
100
+ // delete .che folder
101
+ if (fs.exists((0, path_1.join)(basePath, '.che/project.json'))) {
102
+ fs.delete((0, path_1.join)(basePath, '.che/'));
103
+ }
104
+ // delete neo-app.json
105
+ if (fs.exists((0, path_1.join)(basePath, 'neo-app.json'))) {
106
+ fs.delete((0, path_1.join)(basePath, 'neo-app.json'));
107
+ }
108
+ yield writeUi5Yaml(basePath, fullConfig, fs);
109
+ return fs;
110
+ });
111
+ }
112
+ exports.migrate = migrate;
76
113
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aadp-tooling"
11
11
  },
12
- "version": "0.9.28",
12
+ "version": "0.10.1",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",