@vamship/build-utils 2.4.3 → 2.5.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.
- package/package.json +1 -1
- package/src/project.js +22 -3
- package/src/schema/project-definition.js +6 -0
- package/src/task-builders/copy-files-task-builder.js +9 -1
- package/src/task-builders/package-task-builder.js +2 -6
- package/src/task-builders/publish-task-builder.js +2 -8
- package/src/task-factories/ui-task-factory.js +21 -1
package/package.json
CHANGED
package/src/project.js
CHANGED
@@ -45,6 +45,7 @@ export class Project {
|
|
45
45
|
type,
|
46
46
|
language,
|
47
47
|
requiredEnv,
|
48
|
+
staticDirs,
|
48
49
|
staticFilePatterns,
|
49
50
|
aws,
|
50
51
|
container,
|
@@ -63,7 +64,7 @@ export class Project {
|
|
63
64
|
);
|
64
65
|
}
|
65
66
|
|
66
|
-
if (aws
|
67
|
+
if (aws?.stacks && Object.keys(aws.stacks).length <= 0) {
|
67
68
|
throw new Error(`No AWS stacks defined`);
|
68
69
|
}
|
69
70
|
|
@@ -75,6 +76,7 @@ export class Project {
|
|
75
76
|
this._type = type;
|
76
77
|
this._language = language;
|
77
78
|
this._staticFilePatterns = staticFilePatterns || [];
|
79
|
+
this._staticDirs = staticDirs || [];
|
78
80
|
this._requiredEnv = requiredEnv || [];
|
79
81
|
this._aws = aws || { stacks: {} };
|
80
82
|
this._cdkTargets = Object.keys(this._aws.stacks).reduce(
|
@@ -103,7 +105,7 @@ export class Project {
|
|
103
105
|
{},
|
104
106
|
);
|
105
107
|
|
106
|
-
|
108
|
+
const rootDir = {
|
107
109
|
src: null,
|
108
110
|
test: {
|
109
111
|
unit: null,
|
@@ -130,7 +132,14 @@ export class Project {
|
|
130
132
|
'.tscache': null,
|
131
133
|
logs: null,
|
132
134
|
'cdk.out': null,
|
133
|
-
}
|
135
|
+
};
|
136
|
+
|
137
|
+
for (const dir of this._staticDirs) {
|
138
|
+
rootDir[dir] = null;
|
139
|
+
rootDir.working[dir] = null;
|
140
|
+
}
|
141
|
+
|
142
|
+
this._rootDir = Directory.createTree('./', rootDir);
|
134
143
|
this._banner = `${_colors.cyan(this._name)}@${_colors.green(
|
135
144
|
this._version,
|
136
145
|
)} (${_colors.blue(this._type)} - ${_colors.yellow(this._language)})`;
|
@@ -237,6 +246,16 @@ export class Project {
|
|
237
246
|
return this._staticFilePatterns.concat([]);
|
238
247
|
}
|
239
248
|
|
249
|
+
/**
|
250
|
+
* Returns a list of static file directories configured for the project.
|
251
|
+
*
|
252
|
+
* @returns {Array} An array of strings used to identify static files
|
253
|
+
* included in the build.
|
254
|
+
*/
|
255
|
+
getStaticDirs() {
|
256
|
+
return this._staticDirs.concat([]);
|
257
|
+
}
|
258
|
+
|
240
259
|
/**
|
241
260
|
* Returns a list of environment variables that must be defined for the
|
242
261
|
* build.
|
@@ -158,6 +158,12 @@ export default {
|
|
158
158
|
* process without any compilation/modification.
|
159
159
|
*/
|
160
160
|
staticFilePatterns: { type: 'array' },
|
161
|
+
|
162
|
+
/**
|
163
|
+
* Any static directories that should be copied over during the build
|
164
|
+
* process without any compilation/modification.
|
165
|
+
*/
|
166
|
+
staticDirs: { type: 'array' },
|
161
167
|
},
|
162
168
|
required: ['type', 'language'],
|
163
169
|
},
|
@@ -69,9 +69,17 @@ export class CopyFilesTaskBuilder extends TaskBuilder {
|
|
69
69
|
.reduce((result, arr) => result.concat(arr), [])
|
70
70
|
.concat(extras.map((item) => rootDir.getFileGlob(item)));
|
71
71
|
|
72
|
+
const staticPaths = project
|
73
|
+
.getStaticDirs()
|
74
|
+
.map((dir) => rootDir.getChild(dir))
|
75
|
+
.filter((dir) => dir.exists())
|
76
|
+
.map((dir) => dir.getAllFilesGlob());
|
77
|
+
|
78
|
+
const finalPaths = paths.concat(staticPaths);
|
79
|
+
|
72
80
|
const task = () =>
|
73
81
|
_gulp
|
74
|
-
.src(
|
82
|
+
.src(finalPaths, {
|
75
83
|
allowEmpty: true,
|
76
84
|
base: rootDir.globPath,
|
77
85
|
})
|
@@ -64,8 +64,8 @@ export class PackageTaskBuilder extends TaskBuilder {
|
|
64
64
|
else if (type === 'aws-microservice') {
|
65
65
|
return [new PackageAwsTaskBuilder()];
|
66
66
|
}
|
67
|
-
// Type container
|
68
|
-
else if (type === 'container') {
|
67
|
+
// Type container or api or ui
|
68
|
+
else if (type === 'container' || type === 'api' || type === 'ui') {
|
69
69
|
return [new PackageContainerTaskBuilder('default')];
|
70
70
|
}
|
71
71
|
// Type cli
|
@@ -76,10 +76,6 @@ export class PackageTaskBuilder extends TaskBuilder {
|
|
76
76
|
return [new PackageNpmTaskBuilder()];
|
77
77
|
}
|
78
78
|
}
|
79
|
-
// Type api
|
80
|
-
else if (type === 'api') {
|
81
|
-
return [new PackageContainerTaskBuilder('default')];
|
82
|
-
}
|
83
79
|
// Type ui (and potentially others that are not supported)
|
84
80
|
else {
|
85
81
|
return [new NotSupportedTaskBuilder()];
|
@@ -78,8 +78,8 @@ export class PublishTaskBuilder extends TaskBuilder {
|
|
78
78
|
];
|
79
79
|
}
|
80
80
|
}
|
81
|
-
// Type container
|
82
|
-
else if (type === 'container') {
|
81
|
+
// Type container or api or ui
|
82
|
+
else if (type === 'container' || type === 'api' || type === 'ui') {
|
83
83
|
return [
|
84
84
|
new PublishContainerTaskBuilder('default', project.version),
|
85
85
|
];
|
@@ -94,12 +94,6 @@ export class PublishTaskBuilder extends TaskBuilder {
|
|
94
94
|
return [new PublishNpmTaskBuilder()];
|
95
95
|
}
|
96
96
|
}
|
97
|
-
// Type api
|
98
|
-
else if (type === 'api') {
|
99
|
-
return [
|
100
|
-
new PublishContainerTaskBuilder('default', project.version),
|
101
|
-
];
|
102
|
-
}
|
103
97
|
// Type ui (and potentially others that are not supported)
|
104
98
|
else {
|
105
99
|
return [new NotSupportedTaskBuilder()];
|
@@ -8,6 +8,12 @@ import { BuildTaskBuilder } from '../task-builders/build-task-builder.js';
|
|
8
8
|
import { DocsTaskBuilder } from '../task-builders/docs-task-builder.js';
|
9
9
|
import { TestUiTaskBuilder } from '../task-builders/test-ui-task-builder.js';
|
10
10
|
|
11
|
+
import { PackageTaskBuilder } from '../task-builders/package-task-builder.js';
|
12
|
+
import { PublishTaskBuilder } from '../task-builders/publish-task-builder.js';
|
13
|
+
import { generateAdditionalContainerTasks } from '../utils/task-factory-utils.js';
|
14
|
+
import { PublishContainerTaskBuilder } from '../task-builders/publish-container-task-builder.js';
|
15
|
+
import { PackageContainerTaskBuilder } from '../task-builders/package-container-task-builder.js';
|
16
|
+
|
11
17
|
/**
|
12
18
|
* Represents a factory that generates a set of build tasks for a given project
|
13
19
|
* type. This is an abstract class that must be extended to provide a list of
|
@@ -34,6 +40,15 @@ export class UiTaskFactory extends TaskFactory {
|
|
34
40
|
return [];
|
35
41
|
}
|
36
42
|
|
43
|
+
// Helper function to generate the set of tasks for each additional container
|
44
|
+
// if needed
|
45
|
+
const additionalTaskList = (target) => {
|
46
|
+
return [
|
47
|
+
new PackageContainerTaskBuilder(target),
|
48
|
+
new PublishContainerTaskBuilder(target, this._project.version),
|
49
|
+
];
|
50
|
+
};
|
51
|
+
|
37
52
|
return [
|
38
53
|
new CleanTaskBuilder(),
|
39
54
|
new FormatTaskBuilder(),
|
@@ -43,6 +58,11 @@ export class UiTaskFactory extends TaskFactory {
|
|
43
58
|
|
44
59
|
new DocsTaskBuilder(this._project),
|
45
60
|
new BuildTaskBuilder(this._project),
|
46
|
-
|
61
|
+
new PackageTaskBuilder(this._project),
|
62
|
+
new PublishTaskBuilder(this._project),
|
63
|
+
new PublishContainerTaskBuilder('default'),
|
64
|
+
].concat(
|
65
|
+
generateAdditionalContainerTasks(this._project, additionalTaskList),
|
66
|
+
);
|
47
67
|
}
|
48
68
|
}
|