@docupace/pipeline 1.0.50 → 1.0.51

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docupace/pipeline",
3
- "version": "1.0.50",
3
+ "version": "1.0.51",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/next/cli.js CHANGED
@@ -109,8 +109,10 @@ program
109
109
  .description('Deploy an application for a specific site')
110
110
  .action(async (tagPrefix) => {
111
111
  const deployTag = await getDeployTag(tagPrefix);
112
- const { env, site } = await getDefaultDeploySite(deployTag);
113
- await deployTemplate(env, site, deployTag);
112
+ const sites = await getDefaultDeploySite(deployTag);
113
+ for (const { env, site } of sites) {
114
+ await deployTemplate(env, site, deployTag);
115
+ }
114
116
  });
115
117
 
116
118
  program
@@ -118,8 +120,10 @@ program
118
120
  .description('Deploy an application for a specific site')
119
121
  .action(async () => {
120
122
  const deployTag = await getDeployTag();
121
- const { env, site } = await getDefaultDeploySite(deployTag);
122
- await deployTemplate(env, site, deployTag);
123
+ const sites = await getDefaultDeploySite(deployTag);
124
+ for (const { env, site } of sites) {
125
+ await deployTemplate(env, site, deployTag);
126
+ }
123
127
  });
124
128
 
125
129
  program
@@ -127,8 +131,10 @@ program
127
131
  .description('Deploy an application for a specific site')
128
132
  .action(async (application) => {
129
133
  const deployTag = await getDeployTag();
130
- const { env, site } = await getDefaultDeploySite(deployTag);
131
- await deployAppWithTag(application, env, site, deployTag);
134
+ const sites = await getDefaultDeploySite(deployTag);
135
+ for (const { env, site } of sites) {
136
+ await deployAppWithTag(application, env, site, deployTag);
137
+ }
132
138
  });
133
139
 
134
140
  program
@@ -137,8 +143,10 @@ program
137
143
  .action(async (tag, application) => {
138
144
  const deployTag = await getDeployTag(tag);
139
145
  const version = 'v' + deployTag.split('@')[1];
140
- const { env, site } = await getDefaultDeploySite(version);
141
- await deployAppWithTag(application, env, site, version);
146
+ const sites = await getDefaultDeploySite(version);
147
+ for (const { env, site } of sites) {
148
+ await deployAppWithTag(application, env, site, version);
149
+ }
142
150
  });
143
151
 
144
152
  program
@@ -274,10 +274,40 @@ export async function getDeployTag(prefix = 'v') {
274
274
  return deployTag;
275
275
  }
276
276
 
277
+ function getDeploymentTargets(tag, config) {
278
+ const semverRegex = /^v?(\d+)\.(\d+)\.(\d+)(?:-([\w.\-]+))?$/;
279
+ const match = tag.match(semverRegex);
280
+
281
+ if (!match) {
282
+ throw new Error(`Invalid tag format: ${tag}`);
283
+ }
284
+
285
+ const [_, major, minor, patch, preRelease] = match;
286
+ const isAlpha = preRelease && preRelease.toLowerCase().includes('alpha');
287
+
288
+ return config
289
+ .filter((entry) => {
290
+ if (entry.version.toLowerCase() === 'alpha' && isAlpha) {
291
+ return true;
292
+ }
293
+
294
+ const [entryMajor, entryMinor] = entry.version.split('.');
295
+ return (
296
+ !isAlpha &&
297
+ parseInt(entryMajor) === parseInt(major) &&
298
+ parseInt(entryMinor) === parseInt(minor)
299
+ );
300
+ })
301
+ .map((entry) => ({ env: entry.env, site: entry.site }));
302
+ }
303
+
277
304
  export async function getDefaultDeploySite(deployTag) {
278
- const env = deployTag.includes('alpha') ? 'dev' : 'qa';
279
- const site = env === 'dev' ? 'financialdev' : 'qa';
280
- return { env, site };
305
+ const repPath = await cloneEnvRepository('dev');
306
+ const autoDeployConfigPath = path.resolve(repPath, 'auto-deploy.yaml');
307
+ const autoDeployConfig = yaml.load(
308
+ fs.readFileSync(autoDeployConfigPath, 'utf8'),
309
+ );
310
+ return getDeploymentTargets(deployTag, autoDeployConfig);
281
311
  }
282
312
 
283
313
  export async function deployTemplate(env, site, deployTag) {