@contentstack/cli-variants 2.0.0-beta.2 → 2.0.0-beta.4

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.
@@ -27,7 +27,7 @@ class ExportAttributes extends utils_1.PersonalizationAdapter {
27
27
  this.exportConfig = exportConfig;
28
28
  this.personalizeConfig = exportConfig.modules.personalize;
29
29
  this.attributesConfig = exportConfig.modules.attributes;
30
- this.attributesFolderPath = (0, node_path_1.resolve)((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(this.attributesConfig.dirName));
30
+ this.attributesFolderPath = (0, node_path_1.resolve)((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(this.attributesConfig.dirName));
31
31
  this.attributes = [];
32
32
  this.exportConfig.context.module = constants_1.MODULE_CONTEXTS.ATTRIBUTES;
33
33
  }
@@ -27,7 +27,7 @@ class ExportAudiences extends utils_1.PersonalizationAdapter {
27
27
  this.exportConfig = exportConfig;
28
28
  this.personalizeConfig = exportConfig.modules.personalize;
29
29
  this.audiencesConfig = exportConfig.modules.audiences;
30
- this.audiencesFolderPath = (0, node_path_1.resolve)((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(this.audiencesConfig.dirName));
30
+ this.audiencesFolderPath = (0, node_path_1.resolve)((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(this.audiencesConfig.dirName));
31
31
  this.audiences = [];
32
32
  this.exportConfig.context.module = constants_1.MODULE_CONTEXTS.AUDIENCES;
33
33
  }
@@ -51,7 +51,7 @@ class ExportAudiences extends utils_1.PersonalizationAdapter {
51
51
  }));
52
52
  if (!((_a = this.audiences) === null || _a === void 0 ? void 0 : _a.length)) {
53
53
  cli_utilities_1.log.debug('No audiences found, completing export', this.exportConfig.context);
54
- cli_utilities_1.log.info('No Audiences found with the given project!', this.exportConfig.context);
54
+ cli_utilities_1.log.info('No audiences found for the given project.', this.exportConfig.context);
55
55
  return;
56
56
  }
57
57
  let progress;
@@ -27,7 +27,7 @@ class ExportEvents extends utils_1.PersonalizationAdapter {
27
27
  this.exportConfig = exportConfig;
28
28
  this.personalizeConfig = exportConfig.modules.personalize;
29
29
  this.eventsConfig = exportConfig.modules.events;
30
- this.eventsFolderPath = (0, node_path_1.resolve)((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(this.eventsConfig.dirName));
30
+ this.eventsFolderPath = (0, node_path_1.resolve)((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(this.eventsConfig.dirName));
31
31
  this.events = [];
32
32
  this.exportConfig.context.module = constants_1.MODULE_CONTEXTS.EVENTS;
33
33
  }
@@ -59,7 +59,7 @@ class ExportExperiences extends utils_1.PersonalizationAdapter {
59
59
  });
60
60
  this.exportConfig = exportConfig;
61
61
  this.personalizeConfig = exportConfig.modules.personalize;
62
- this.experiencesFolderPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), 'experiences');
62
+ this.experiencesFolderPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), 'experiences');
63
63
  this.exportConfig.context.module = constants_1.MODULE_CONTEXTS.EXPERIENCES;
64
64
  }
65
65
  start() {
@@ -86,7 +86,7 @@ class ExportExperiences extends utils_1.PersonalizationAdapter {
86
86
  }));
87
87
  if (!experiences || (experiences === null || experiences === void 0 ? void 0 : experiences.length) < 1) {
88
88
  cli_utilities_1.log.debug('No experiences found, completing export', this.exportConfig.context);
89
- cli_utilities_1.log.info('No Experiences found with the given project!', this.exportConfig.context);
89
+ cli_utilities_1.log.info('No experiences found for the given project.', this.exportConfig.context);
90
90
  return;
91
91
  }
92
92
  let progress;
@@ -22,7 +22,7 @@ class ExportProjects extends utils_1.PersonalizationAdapter {
22
22
  });
23
23
  this.exportConfig = exportConfig;
24
24
  this.personalizeConfig = exportConfig.modules.personalize;
25
- this.projectsFolderPath = (0, node_path_1.resolve)((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), 'projects');
25
+ this.projectsFolderPath = (0, node_path_1.resolve)((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), 'projects');
26
26
  this.projectsData = [];
27
27
  this.exportConfig.context.module = constants_1.MODULE_CONTEXTS.PROJECTS;
28
28
  }
@@ -68,7 +68,7 @@ class VariantEntries extends variant_api_adapter_1.default {
68
68
  this.processInitialized = false;
69
69
  this.totalVariantCount = 0;
70
70
  this.processedVariantCount = 0;
71
- this.entriesDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(config.data), (0, cli_utilities_1.sanitizePath)(config.branchName || ''), (0, cli_utilities_1.sanitizePath)(config.modules.entries.dirName));
71
+ this.entriesDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(config.exportDir), (0, cli_utilities_1.sanitizePath)(config.branchName || ''), (0, cli_utilities_1.sanitizePath)(config.modules.entries.dirName));
72
72
  if (this.config && this.config.context) {
73
73
  this.config.context.module = 'variant-entries';
74
74
  }
@@ -112,7 +112,7 @@ class Attribute extends utils_1.PersonalizationAdapter {
112
112
  return this.withLoadingSpinner('ATTRIBUTES: Analyzing import data...', () => __awaiter(this, void 0, void 0, function* () {
113
113
  var _a;
114
114
  const { dirName, fileName } = this.attributeConfig;
115
- const attributesPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.data), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(dirName), (0, cli_utilities_1.sanitizePath)(fileName));
115
+ const attributesPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.contentDir), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(dirName), (0, cli_utilities_1.sanitizePath)(fileName));
116
116
  cli_utilities_1.log.debug(`Checking for attributes file: ${attributesPath}`, this.config.context);
117
117
  if (!(0, fs_1.existsSync)(attributesPath)) {
118
118
  cli_utilities_1.log.warn(`Attributes file not found: ${attributesPath}`, this.config.context);
@@ -118,7 +118,7 @@ class Audiences extends utils_1.PersonalizationAdapter {
118
118
  return this.withLoadingSpinner('AUDIENCES: Analyzing import data...', () => __awaiter(this, void 0, void 0, function* () {
119
119
  var _a;
120
120
  const { dirName, fileName } = this.audienceConfig;
121
- const audiencesPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.data), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(dirName), (0, cli_utilities_1.sanitizePath)(fileName));
121
+ const audiencesPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.contentDir), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(dirName), (0, cli_utilities_1.sanitizePath)(fileName));
122
122
  cli_utilities_1.log.debug(`Checking for audiences file: ${audiencesPath}`, this.config.context);
123
123
  if (!(0, fs_1.existsSync)(audiencesPath)) {
124
124
  cli_utilities_1.log.warn(`Audiences file not found: ${audiencesPath}`, this.config.context);
@@ -115,7 +115,7 @@ class Events extends utils_1.PersonalizationAdapter {
115
115
  return this.withLoadingSpinner('EVENTS: Analyzing import data...', () => __awaiter(this, void 0, void 0, function* () {
116
116
  var _a;
117
117
  const { dirName, fileName } = this.eventConfig;
118
- const eventsPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.data), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(dirName), (0, cli_utilities_1.sanitizePath)(fileName));
118
+ const eventsPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.contentDir), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(dirName), (0, cli_utilities_1.sanitizePath)(fileName));
119
119
  cli_utilities_1.log.debug(`Checking for events file: ${eventsPath}`, this.config.context);
120
120
  if (!(0, fs_1.existsSync)(eventsPath)) {
121
121
  cli_utilities_1.log.warn(`Events file not found: ${eventsPath}`, this.config.context);
@@ -45,7 +45,7 @@ class Experiences extends utils_1.PersonalizationAdapter {
45
45
  super(Object.assign(config, conf));
46
46
  this.config = config;
47
47
  this.personalizeConfig = this.config.modules.personalize;
48
- this.experiencesDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.data), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.experiences.dirName));
48
+ this.experiencesDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.contentDir), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.experiences.dirName));
49
49
  this.experiencesPath = (0, path_1.join)((0, cli_utilities_1.sanitizePath)(this.experiencesDirPath), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.experiences.fileName));
50
50
  this.experienceConfig = this.personalizeConfig.experiences;
51
51
  this.audienceConfig = this.personalizeConfig.audiences;
@@ -59,7 +59,7 @@ class Experiences extends utils_1.PersonalizationAdapter {
59
59
  this.failedCmsExpPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.expMapperDirPath), 'failed-cms-experience.json');
60
60
  this.failedCmsExpPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.expMapperDirPath), 'failed-cms-experience.json');
61
61
  this.experienceCTsPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.experiencesDirPath), 'experiences-content-types.json');
62
- this.experienceVariantsIdsPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.data), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(this.experienceConfig.dirName), 'experiences-variants-ids.json');
62
+ this.experienceVariantsIdsPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.contentDir), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(this.experienceConfig.dirName), 'experiences-variants-ids.json');
63
63
  this.variantUidMapperFilePath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.expMapperDirPath), 'variants-uid-mapping.json');
64
64
  this.experiencesUidMapper = {};
65
65
  this.cmsVariantGroups = {};
@@ -117,7 +117,7 @@ class Project extends utils_1.PersonalizationAdapter {
117
117
  var _a;
118
118
  const personalize = this.config.modules.personalize;
119
119
  const { dirName, fileName } = personalize.projects;
120
- const projectPath = (0, path_1.join)((0, cli_utilities_1.sanitizePath)(this.config.data), (0, cli_utilities_1.sanitizePath)(personalize.dirName), (0, cli_utilities_1.sanitizePath)(dirName), (0, cli_utilities_1.sanitizePath)(fileName));
120
+ const projectPath = (0, path_1.join)((0, cli_utilities_1.sanitizePath)(this.config.contentDir), (0, cli_utilities_1.sanitizePath)(personalize.dirName), (0, cli_utilities_1.sanitizePath)(dirName), (0, cli_utilities_1.sanitizePath)(fileName));
121
121
  cli_utilities_1.log.debug(`Checking for project file: ${projectPath}`, this.config.context);
122
122
  if (!(0, fs_1.existsSync)(projectPath)) {
123
123
  this.config.modules.personalize.importData = false;
@@ -4,7 +4,7 @@
4
4
  * Therefore, we are duplicating the following types from the export.
5
5
  */
6
6
  import { AnyProperty, Context } from './utils';
7
- export type Modules = 'stack' | 'assets' | 'locales' | 'environments' | 'extensions' | 'webhooks' | 'global-fields' | 'entries' | 'content-types' | 'custom-roles' | 'workflows' | 'labels' | 'marketplace-apps' | 'taxonomies' | 'personalize';
7
+ export type Modules = 'stack' | 'assets' | 'locales' | 'environments' | 'extensions' | 'webhooks' | 'global-fields' | 'entries' | 'content-types' | 'custom-roles' | 'workflows' | 'labels' | 'marketplace-apps' | 'taxonomies' | 'personalize' | 'composable-studio';
8
8
  export type branch = {
9
9
  uid: string;
10
10
  source: string;
@@ -158,6 +158,11 @@ export interface DefaultConfig {
158
158
  fileName: string;
159
159
  dependencies?: Modules[];
160
160
  };
161
+ 'composable-studio': {
162
+ dirName: string;
163
+ fileName: string;
164
+ apiBaseUrl: string;
165
+ };
161
166
  masterLocale: {
162
167
  dirName: string;
163
168
  fileName: string;
@@ -6,7 +6,6 @@ export interface LogType {
6
6
  (config: any, message: any, type: 'info' | 'error' | 'success'): void;
7
7
  }
8
8
  export interface Context {
9
- command: string;
10
9
  module: string;
11
10
  userId: string | undefined;
12
11
  email?: string | undefined;
@@ -156,7 +156,7 @@ function init(_logPath, module) {
156
156
  };
157
157
  }
158
158
  const log = (config, message, type) => {
159
- const logsPath = config.data;
159
+ const logsPath = 'exportDir' in config ? config.exportDir : 'contentDir' in config ? config.contentDir : config.data;
160
160
  // ignoring the type argument, as we are not using it to create a logfile anymore
161
161
  const module = config['backupDir'] ? 'import' : 'export';
162
162
  if (type !== 'error') {
@@ -46,11 +46,11 @@ class VariantHttpClient extends adapter_helper_1.AdapterHelper {
46
46
  const token = cli_utilities_1.authenticationHandler.accessToken;
47
47
  cli_utilities_1.log.debug(`Authentication type: ${cli_utilities_1.authenticationHandler.isOauthEnabled ? 'OAuth' : 'Token'}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
48
48
  if (cli_utilities_1.authenticationHandler.isOauthEnabled) {
49
- cli_utilities_1.log.debug('Setting OAuth authorization header', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
49
+ cli_utilities_1.log.debug('Setting OAuth authorization header...', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
50
50
  this.apiClient.headers({ authorization: token });
51
51
  }
52
52
  else {
53
- cli_utilities_1.log.debug('Setting authtoken header', (_d = this.exportConfig) === null || _d === void 0 ? void 0 : _d.context);
53
+ cli_utilities_1.log.debug('Setting authtoken header...', (_d = this.exportConfig) === null || _d === void 0 ? void 0 : _d.context);
54
54
  this.apiClient.headers({ authtoken: token });
55
55
  }
56
56
  });
@@ -83,7 +83,7 @@ class VariantHttpClient extends adapter_helper_1.AdapterHelper {
83
83
  cli_utilities_1.log.debug(`Fetching variant entries for content type: ${content_type_uid}, entry: ${entry_uid}, locale: ${locale}`, (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
84
84
  cli_utilities_1.log.debug(`Query parameters - skip: ${skip}, limit: ${limit}, include_variant: ${include_variant}, include_count: ${include_count}, include_publish_details: ${include_publish_details}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
85
85
  if (variantConfig.serveMockData && callback) {
86
- cli_utilities_1.log.debug('Using mock data for variant entries', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
86
+ cli_utilities_1.log.debug('Using mock data for variant entries...', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
87
87
  let data = [];
88
88
  if ((0, fs_1.existsSync)(variantConfig.mockDataPath)) {
89
89
  cli_utilities_1.log.debug(`Loading mock data from: ${variantConfig.mockDataPath}`, (_d = this.exportConfig) === null || _d === void 0 ? void 0 : _d.context);
@@ -131,11 +131,11 @@ class VariantHttpClient extends adapter_helper_1.AdapterHelper {
131
131
  cli_utilities_1.log.debug(`Received ${(_h = response.entries) === null || _h === void 0 ? void 0 : _h.length} variant entries out of total ${response.count}`, (_j = this.exportConfig) === null || _j === void 0 ? void 0 : _j.context);
132
132
  }
133
133
  if (callback) {
134
- cli_utilities_1.log.debug('Executing callback with variant entries', (_k = this.exportConfig) === null || _k === void 0 ? void 0 : _k.context);
134
+ cli_utilities_1.log.debug('Executing callback with variant entries...', (_k = this.exportConfig) === null || _k === void 0 ? void 0 : _k.context);
135
135
  callback(response.entries);
136
136
  }
137
137
  else {
138
- cli_utilities_1.log.debug('Adding variant entries to collection', (_l = this.exportConfig) === null || _l === void 0 ? void 0 : _l.context);
138
+ cli_utilities_1.log.debug('Adding variant entries to collection...', (_l = this.exportConfig) === null || _l === void 0 ? void 0 : _l.context);
139
139
  entries = entries.concat(response.entries);
140
140
  }
141
141
  if (getAllData && skip + limit < response.count) {
@@ -154,7 +154,7 @@ class VariantHttpClient extends adapter_helper_1.AdapterHelper {
154
154
  return yield this.variantEntries(options, entries);
155
155
  }
156
156
  if (returnResult) {
157
- cli_utilities_1.log.debug('Returning variant entries result', (_p = this.exportConfig) === null || _p === void 0 ? void 0 : _p.context);
157
+ cli_utilities_1.log.debug('Returning variant entries result...', (_p = this.exportConfig) === null || _p === void 0 ? void 0 : _p.context);
158
158
  return { entries };
159
159
  }
160
160
  });
@@ -264,7 +264,7 @@ class VariantHttpClient extends adapter_helper_1.AdapterHelper {
264
264
  const { status, data } = res;
265
265
  cli_utilities_1.log.debug(`API response status: ${status}`, (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
266
266
  if (status >= 200 && status < 300) {
267
- cli_utilities_1.log.debug('API request successful', (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
267
+ cli_utilities_1.log.debug('API request successful.', (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
268
268
  return data;
269
269
  }
270
270
  cli_utilities_1.log.debug(`API request failed with status: ${status}`, (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
@@ -324,17 +324,17 @@ class VariantAdapter {
324
324
  this.currentModuleName = '';
325
325
  cli_utilities_1.log.debug('Initializing VariantAdapter...', (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
326
326
  if (config.httpClient) {
327
- cli_utilities_1.log.debug('Using HTTP client variant instance', (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
327
+ cli_utilities_1.log.debug('Using HTTP client variant instance.', (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
328
328
  const { httpClient, Adapter } = config, restConfig = __rest(config, ["httpClient", "Adapter"]);
329
329
  this.variantInstance = new Adapter(restConfig, options);
330
330
  }
331
331
  else {
332
- cli_utilities_1.log.debug('Using SDK variant instance', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
332
+ cli_utilities_1.log.debug('Using SDK variant instance.', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
333
333
  const { Adapter } = config, restConfig = __rest(config, ["Adapter"]);
334
334
  this.variantInstance = new Adapter(restConfig);
335
335
  }
336
336
  this.messages = messages_1.default;
337
- cli_utilities_1.log.debug('VariantAdapter initialized successfully', (_d = this.exportConfig) === null || _d === void 0 ? void 0 : _d.context);
337
+ cli_utilities_1.log.debug('VariantAdapter initialized successfully.', (_d = this.exportConfig) === null || _d === void 0 ? void 0 : _d.context);
338
338
  }
339
339
  /**
340
340
  * Set parent progress manager for sub-module integration
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/cli-variants",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.4",
4
4
  "description": "Variants plugin",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -27,7 +27,7 @@
27
27
  "typescript": "^5.8.3"
28
28
  },
29
29
  "dependencies": {
30
- "@contentstack/cli-utilities": "~1.15.0",
30
+ "@contentstack/cli-utilities": "~1.17.0",
31
31
  "@oclif/core": "^4.3.0",
32
32
  "@oclif/plugin-help": "^6.2.28",
33
33
  "lodash": "^4.17.21",
@@ -22,7 +22,7 @@ export default class ExportAttributes extends PersonalizationAdapter<ExportConfi
22
22
  this.personalizeConfig = exportConfig.modules.personalize;
23
23
  this.attributesConfig = exportConfig.modules.attributes;
24
24
  this.attributesFolderPath = pResolve(
25
- sanitizePath(exportConfig.data),
25
+ sanitizePath(exportConfig.exportDir),
26
26
  sanitizePath(exportConfig.branchName || ''),
27
27
  sanitizePath(this.personalizeConfig.dirName),
28
28
  sanitizePath(this.attributesConfig.dirName),
@@ -22,7 +22,7 @@ export default class ExportAudiences extends PersonalizationAdapter<ExportConfig
22
22
  this.personalizeConfig = exportConfig.modules.personalize;
23
23
  this.audiencesConfig = exportConfig.modules.audiences;
24
24
  this.audiencesFolderPath = pResolve(
25
- sanitizePath(exportConfig.data),
25
+ sanitizePath(exportConfig.exportDir),
26
26
  sanitizePath(exportConfig.branchName || ''),
27
27
  sanitizePath(this.personalizeConfig.dirName),
28
28
  sanitizePath(this.audiencesConfig.dirName),
@@ -52,7 +52,7 @@ export default class ExportAudiences extends PersonalizationAdapter<ExportConfig
52
52
 
53
53
  if (!this.audiences?.length) {
54
54
  log.debug('No audiences found, completing export', this.exportConfig.context);
55
- log.info('No Audiences found with the given project!', this.exportConfig.context);
55
+ log.info('No audiences found for the given project.', this.exportConfig.context);
56
56
  return;
57
57
  }
58
58
 
@@ -22,7 +22,7 @@ export default class ExportEvents extends PersonalizationAdapter<ExportConfig> {
22
22
  this.personalizeConfig = exportConfig.modules.personalize;
23
23
  this.eventsConfig = exportConfig.modules.events;
24
24
  this.eventsFolderPath = pResolve(
25
- sanitizePath(exportConfig.data),
25
+ sanitizePath(exportConfig.exportDir),
26
26
  sanitizePath(exportConfig.branchName || ''),
27
27
  sanitizePath(this.personalizeConfig.dirName),
28
28
  sanitizePath(this.eventsConfig.dirName),
@@ -22,7 +22,7 @@ export default class ExportExperiences extends PersonalizationAdapter<ExportConf
22
22
  this.exportConfig = exportConfig;
23
23
  this.personalizeConfig = exportConfig.modules.personalize;
24
24
  this.experiencesFolderPath = path.resolve(
25
- sanitizePath(exportConfig.data),
25
+ sanitizePath(exportConfig.exportDir),
26
26
  sanitizePath(exportConfig.branchName || ''),
27
27
  sanitizePath(this.personalizeConfig.dirName),
28
28
  'experiences',
@@ -61,7 +61,7 @@ export default class ExportExperiences extends PersonalizationAdapter<ExportConf
61
61
 
62
62
  if (!experiences || experiences?.length < 1) {
63
63
  log.debug('No experiences found, completing export', this.exportConfig.context);
64
- log.info('No Experiences found with the given project!', this.exportConfig.context);
64
+ log.info('No experiences found for the given project.', this.exportConfig.context);
65
65
  return;
66
66
  }
67
67
 
@@ -19,7 +19,7 @@ export default class ExportProjects extends PersonalizationAdapter<ExportConfig>
19
19
  this.exportConfig = exportConfig;
20
20
  this.personalizeConfig = exportConfig.modules.personalize;
21
21
  this.projectsFolderPath = pResolve(
22
- sanitizePath(exportConfig.data),
22
+ sanitizePath(exportConfig.exportDir),
23
23
  sanitizePath(exportConfig.branchName || ''),
24
24
  sanitizePath(this.personalizeConfig.dirName),
25
25
  'projects',
@@ -31,7 +31,7 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Exp
31
31
  };
32
32
  super(Object.assign(config, conf));
33
33
  this.entriesDirPath = resolve(
34
- sanitizePath(config.data),
34
+ sanitizePath(config.exportDir),
35
35
  sanitizePath(config.branchName || ''),
36
36
  sanitizePath(config.modules.entries.dirName),
37
37
  );
@@ -124,7 +124,7 @@ export default class Attribute extends PersonalizationAdapter<ImportConfig> {
124
124
  return this.withLoadingSpinner('ATTRIBUTES: Analyzing import data...', async () => {
125
125
  const { dirName, fileName } = this.attributeConfig;
126
126
  const attributesPath = resolve(
127
- sanitizePath(this.config.data),
127
+ sanitizePath(this.config.contentDir),
128
128
  sanitizePath(this.personalizeConfig.dirName),
129
129
  sanitizePath(dirName),
130
130
  sanitizePath(fileName),
@@ -138,7 +138,7 @@ export default class Audiences extends PersonalizationAdapter<ImportConfig> {
138
138
  return this.withLoadingSpinner('AUDIENCES: Analyzing import data...', async () => {
139
139
  const { dirName, fileName } = this.audienceConfig;
140
140
  const audiencesPath = resolve(
141
- sanitizePath(this.config.data),
141
+ sanitizePath(this.config.contentDir),
142
142
  sanitizePath(this.personalizeConfig.dirName),
143
143
  sanitizePath(dirName),
144
144
  sanitizePath(fileName),
@@ -123,7 +123,7 @@ export default class Events extends PersonalizationAdapter<ImportConfig> {
123
123
  return this.withLoadingSpinner('EVENTS: Analyzing import data...', async () => {
124
124
  const { dirName, fileName } = this.eventConfig;
125
125
  const eventsPath = resolve(
126
- sanitizePath(this.config.data),
126
+ sanitizePath(this.config.contentDir),
127
127
  sanitizePath(this.personalizeConfig.dirName),
128
128
  sanitizePath(dirName),
129
129
  sanitizePath(fileName),
@@ -57,7 +57,7 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
57
57
 
58
58
  this.personalizeConfig = this.config.modules.personalize;
59
59
  this.experiencesDirPath = resolve(
60
- sanitizePath(this.config.data),
60
+ sanitizePath(this.config.contentDir),
61
61
  sanitizePath(this.personalizeConfig.dirName),
62
62
  sanitizePath(this.personalizeConfig.experiences.dirName),
63
63
  );
@@ -86,7 +86,7 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
86
86
  this.failedCmsExpPath = resolve(sanitizePath(this.expMapperDirPath), 'failed-cms-experience.json');
87
87
  this.experienceCTsPath = resolve(sanitizePath(this.experiencesDirPath), 'experiences-content-types.json');
88
88
  this.experienceVariantsIdsPath = resolve(
89
- sanitizePath(this.config.data),
89
+ sanitizePath(this.config.contentDir),
90
90
  sanitizePath(this.personalizeConfig.dirName),
91
91
  sanitizePath(this.experienceConfig.dirName),
92
92
  'experiences-variants-ids.json',
@@ -133,7 +133,7 @@ export default class Project extends PersonalizationAdapter<ImportConfig> {
133
133
  const personalize = this.config.modules.personalize;
134
134
  const { dirName, fileName } = personalize.projects;
135
135
  const projectPath = join(
136
- sanitizePath(this.config.data),
136
+ sanitizePath(this.config.contentDir),
137
137
  sanitizePath(personalize.dirName),
138
138
  sanitizePath(dirName),
139
139
  sanitizePath(fileName),
@@ -20,7 +20,8 @@ export type Modules =
20
20
  | 'labels'
21
21
  | 'marketplace-apps'
22
22
  | 'taxonomies'
23
- | 'personalize';
23
+ | 'personalize'
24
+ | 'composable-studio';
24
25
 
25
26
  export type branch = {
26
27
  uid: string;
@@ -182,6 +183,11 @@ export interface DefaultConfig {
182
183
  fileName: string;
183
184
  dependencies?: Modules[];
184
185
  };
186
+ 'composable-studio': {
187
+ dirName: string;
188
+ fileName: string;
189
+ apiBaseUrl: string;
190
+ };
185
191
  masterLocale: {
186
192
  dirName: string;
187
193
  fileName: string;
@@ -8,7 +8,6 @@ export interface LogType {
8
8
  }
9
9
 
10
10
  export interface Context {
11
- command: string;
12
11
  module: string;
13
12
  userId: string | undefined;
14
13
  email?: string | undefined;
@@ -132,7 +132,7 @@ function init(_logPath: string, module: string) {
132
132
  }
133
133
 
134
134
  export const log = (config: ExportConfig | ImportConfig, message: any, type: 'info' | 'error' | 'success') => {
135
- const logsPath = config.data;
135
+ const logsPath = 'exportDir' in config ? config.exportDir : 'contentDir' in config ? config.contentDir : (config as any).data;
136
136
  // ignoring the type argument, as we are not using it to create a logfile anymore
137
137
  const module = (config as ImportConfig)['backupDir'] ? 'import' : 'export';
138
138
  if (type !== 'error') {
@@ -53,10 +53,10 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement
53
53
  this.exportConfig?.context,
54
54
  );
55
55
  if (authenticationHandler.isOauthEnabled) {
56
- log.debug('Setting OAuth authorization header', this.exportConfig?.context);
56
+ log.debug('Setting OAuth authorization header...', this.exportConfig?.context);
57
57
  this.apiClient.headers({ authorization: token });
58
58
  } else {
59
- log.debug('Setting authtoken header', this.exportConfig?.context);
59
+ log.debug('Setting authtoken header...', this.exportConfig?.context);
60
60
  this.apiClient.headers({ authtoken: token });
61
61
  }
62
62
  }
@@ -109,7 +109,7 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement
109
109
  );
110
110
 
111
111
  if (variantConfig.serveMockData && callback) {
112
- log.debug('Using mock data for variant entries', this.exportConfig?.context);
112
+ log.debug('Using mock data for variant entries...', this.exportConfig?.context);
113
113
  let data = [] as Record<string, any>[];
114
114
 
115
115
  if (existsSync(variantConfig.mockDataPath)) {
@@ -174,10 +174,10 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement
174
174
  }
175
175
 
176
176
  if (callback) {
177
- log.debug('Executing callback with variant entries', this.exportConfig?.context);
177
+ log.debug('Executing callback with variant entries...', this.exportConfig?.context);
178
178
  callback(response.entries);
179
179
  } else {
180
- log.debug('Adding variant entries to collection', this.exportConfig?.context);
180
+ log.debug('Adding variant entries to collection...', this.exportConfig?.context);
181
181
  entries = entries.concat(response.entries);
182
182
  }
183
183
 
@@ -200,7 +200,7 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement
200
200
  }
201
201
 
202
202
  if (returnResult) {
203
- log.debug('Returning variant entries result', this.exportConfig?.context );
203
+ log.debug('Returning variant entries result...', this.exportConfig?.context );
204
204
  return { entries };
205
205
  }
206
206
  }
@@ -329,7 +329,7 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement
329
329
  log.debug(`API response status: ${status}`, this.exportConfig?.context);
330
330
 
331
331
  if (status >= 200 && status < 300) {
332
- log.debug('API request successful', this.exportConfig?.context);
332
+ log.debug('API request successful.', this.exportConfig?.context);
333
333
  return data;
334
334
  }
335
335
 
@@ -406,17 +406,17 @@ export class VariantAdapter<T> {
406
406
  log.debug('Initializing VariantAdapter...', this.exportConfig?.context);
407
407
 
408
408
  if (config.httpClient) {
409
- log.debug('Using HTTP client variant instance', this.exportConfig?.context);
409
+ log.debug('Using HTTP client variant instance.', this.exportConfig?.context);
410
410
  const { httpClient, Adapter, ...restConfig } = config;
411
411
  this.variantInstance = new Adapter(restConfig, options);
412
412
  } else {
413
- log.debug('Using SDK variant instance', this.exportConfig?.context);
413
+ log.debug('Using SDK variant instance.', this.exportConfig?.context);
414
414
  const { Adapter, ...restConfig } = config;
415
415
  this.variantInstance = new Adapter(restConfig);
416
416
  }
417
417
 
418
418
  this.messages = messages;
419
- log.debug('VariantAdapter initialized successfully', this.exportConfig?.context);
419
+ log.debug('VariantAdapter initialized successfully.', this.exportConfig?.context);
420
420
  }
421
421
 
422
422
  /**