@vamship/build-utils 1.5.3 → 2.0.0-1
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +40 -51
- package/src/directory.js +36 -24
- package/src/index.js +5 -17
- package/src/project.js +160 -433
- package/src/schema/project-definition.js +137 -0
- package/src/task-builder.js +100 -0
- package/src/task-builders/build-js-task-builder.js +57 -0
- package/src/task-builders/build-task-builder.js +78 -0
- package/src/task-builders/build-ts-task-builder.js +63 -0
- package/src/task-builders/build-ui-task-builder.js +45 -0
- package/src/task-builders/clean-task-builder.js +39 -0
- package/src/task-builders/copy-files-task-builder.js +78 -0
- package/src/task-builders/docs-js-task-builder.js +74 -0
- package/src/task-builders/docs-task-builder.js +74 -0
- package/src/task-builders/docs-ts-task-builder.js +52 -0
- package/src/task-builders/format-task-builder.js +61 -0
- package/src/task-builders/index.js +21 -17
- package/src/task-builders/lint-fix-task-builder.js +61 -0
- package/src/task-builders/lint-task-builder.js +56 -0
- package/src/task-builders/not-supported-task-builder.js +48 -0
- package/src/task-builders/package-aws-task-builder.js +105 -0
- package/src/task-builders/package-container-task-builder.js +132 -0
- package/src/task-builders/package-npm-task-builder.js +83 -0
- package/src/task-builders/package-task-builder.js +101 -0
- package/src/task-builders/publish-aws-task-builder.js +111 -0
- package/src/task-builders/publish-container-task-builder.js +103 -0
- package/src/task-builders/publish-npm-task-builder.js +60 -0
- package/src/task-builders/publish-task-builder.js +98 -0
- package/src/task-builders/test-task-builder.js +85 -0
- package/src/task-builders/test-ui-task-builder.js +65 -0
- package/src/task-builders/watch-task-builder.js +109 -0
- package/src/task-factories/api-task-factory.js +67 -0
- package/src/task-factories/aws-microservice-task-factory.js +53 -0
- package/src/task-factories/cli-task-factory.js +68 -0
- package/src/task-factories/container-task-factory.js +64 -0
- package/src/task-factories/index.js +8 -0
- package/src/task-factories/lib-task-factory.js +52 -0
- package/src/task-factories/ui-task-factory.js +48 -0
- package/src/task-factory.js +52 -0
- package/src/utils/semver-utils.js +29 -0
- package/src/utils/task-factory-utils.js +70 -0
- package/src/task-builders/build/build-js.js +0 -66
- package/src/task-builders/build/build-ts.js +0 -70
- package/src/task-builders/build/build-types.js +0 -47
- package/src/task-builders/build/build-ui.js +0 -67
- package/src/task-builders/build/index.js +0 -60
- package/src/task-builders/clean.js +0 -57
- package/src/task-builders/docs/docs-js.js +0 -41
- package/src/task-builders/docs/docs-ts.js +0 -40
- package/src/task-builders/docs/index.js +0 -32
- package/src/task-builders/format.js +0 -58
- package/src/task-builders/lint.js +0 -56
- package/src/task-builders/package/index.js +0 -50
- package/src/task-builders/package/package-aws.js +0 -58
- package/src/task-builders/package/package-docker.js +0 -128
- package/src/task-builders/package/package-npm.js +0 -25
- package/src/task-builders/package/package-types.js +0 -54
- package/src/task-builders/package/utils.js +0 -50
- package/src/task-builders/publish/index.js +0 -50
- package/src/task-builders/publish/publish-aws.js +0 -62
- package/src/task-builders/publish/publish-docker.js +0 -79
- package/src/task-builders/publish/publish-npm.js +0 -36
- package/src/task-builders/publish/publish-types.js +0 -36
- package/src/task-builders/test/index.js +0 -39
- package/src/task-builders/test/test-ui.js +0 -39
- package/src/task-builders/test/test.js +0 -67
@@ -1,50 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const _gulp = require('gulp');
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Builder function that can be used to generate a gulp task to package a
|
7
|
-
* project for distribution. The task takes on different implementations based
|
8
|
-
* on project types. For example, javascript libraries will yield an archive
|
9
|
-
* resulting from an `npm pack`, while docker enabled projects will result in
|
10
|
-
* the creation of a docker image.
|
11
|
-
*
|
12
|
-
* @param {Object} project Reference to an object that contains project metadata
|
13
|
-
* that can be used to customize build outputs.
|
14
|
-
* @param {Object} options An options object that can be used to customize the
|
15
|
-
* task.
|
16
|
-
*
|
17
|
-
* @returns {Function} A gulp task.
|
18
|
-
*/
|
19
|
-
module.exports = (project, options) => {
|
20
|
-
const { types } = options;
|
21
|
-
let createTask = null;
|
22
|
-
|
23
|
-
if (types) {
|
24
|
-
if (!project.hasExportedTypes) {
|
25
|
-
return;
|
26
|
-
}
|
27
|
-
createTask = require('./package-types');
|
28
|
-
} else if (project.projectType === 'aws-microservice') {
|
29
|
-
createTask = require('./package-aws');
|
30
|
-
} else if (project.hasDocker) {
|
31
|
-
createTask = require('./package-docker');
|
32
|
-
} else if (project.projectType === 'lib' || project.projectType === 'cli') {
|
33
|
-
createTask = require('./package-npm');
|
34
|
-
}
|
35
|
-
|
36
|
-
const task = createTask(project, options);
|
37
|
-
|
38
|
-
if (!(task instanceof Array)) {
|
39
|
-
if (types) {
|
40
|
-
task.displayName = 'package-types';
|
41
|
-
task.description =
|
42
|
-
'Create a distribution package for the types exported by the project';
|
43
|
-
} else {
|
44
|
-
task.displayName = 'package';
|
45
|
-
task.description = 'Create a distribution package for the project';
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
return task;
|
50
|
-
};
|
@@ -1,58 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const _gulp = require('gulp');
|
4
|
-
const _zip = require('gulp-zip');
|
5
|
-
const _execa = require('execa');
|
6
|
-
|
7
|
-
/**
|
8
|
-
* Sub builder that packages an aws-microservice project for deployment. This
|
9
|
-
* follows the build steps described for
|
10
|
-
* [lambda deployments](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-create-deployment-pkg.html#nodejs-package-dependencies)
|
11
|
-
*
|
12
|
-
* @private
|
13
|
-
* @param {Object} project Reference to an object that contains project metadata
|
14
|
-
* that can be used to customize build outputs.
|
15
|
-
* @param {Object} options An options object that can be used to customize the
|
16
|
-
* task.
|
17
|
-
*
|
18
|
-
* @returns {Function} A gulp task.
|
19
|
-
*/
|
20
|
-
module.exports = (project, options) => {
|
21
|
-
const { snakeCasedName, version, rootDir } = project;
|
22
|
-
const workingDir = rootDir.getChild('working');
|
23
|
-
|
24
|
-
const packageName = `${snakeCasedName}-${version}.zip`;
|
25
|
-
|
26
|
-
const installTask = () => {
|
27
|
-
const npmBin = 'npm';
|
28
|
-
const args = ['install', '--production'];
|
29
|
-
|
30
|
-
return _execa(npmBin, args, {
|
31
|
-
stdio: 'inherit',
|
32
|
-
cwd: workingDir.absolutePath,
|
33
|
-
});
|
34
|
-
};
|
35
|
-
|
36
|
-
installTask.displayName = 'package-aws-install';
|
37
|
-
installTask.description = 'Install package dependency in working directory';
|
38
|
-
|
39
|
-
const dirs = ['src', 'node_modules'];
|
40
|
-
const extras = ['package.json', project.configFileName];
|
41
|
-
|
42
|
-
const paths = dirs
|
43
|
-
.map((dir) => workingDir.getChild(dir))
|
44
|
-
.map((dir) => dir.getAllFilesGlob())
|
45
|
-
.concat(extras.map((file) => workingDir.getFileGlob(file)));
|
46
|
-
|
47
|
-
const zipTask = () =>
|
48
|
-
_gulp
|
49
|
-
.src(paths, { allowEmpty: true, base: workingDir.globPath })
|
50
|
-
.pipe(_zip(packageName))
|
51
|
-
.pipe(_gulp.dest(rootDir.getChild('dist').absolutePath));
|
52
|
-
|
53
|
-
zipTask.displayName = 'package-aws-zip';
|
54
|
-
zipTask.description =
|
55
|
-
'Create a project distribution for AWS lambda deployments';
|
56
|
-
|
57
|
-
return _gulp.series([installTask, zipTask]);
|
58
|
-
};
|
@@ -1,128 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const _execa = require('execa');
|
4
|
-
const _gulp = require('gulp');
|
5
|
-
const _log = require('fancy-log');
|
6
|
-
const _mkdirp = require('mkdirp');
|
7
|
-
|
8
|
-
/**
|
9
|
-
* Sub builder that builds a docker image based on a predefined dockerfile.
|
10
|
-
*
|
11
|
-
* @private
|
12
|
-
* @param {Object} project Reference to an object that contains project metadata
|
13
|
-
* that can be used to customize build outputs.
|
14
|
-
* @param {Object} options An options object that can be used to customize the
|
15
|
-
* task.
|
16
|
-
*
|
17
|
-
* @returns {Function} A gulp task.
|
18
|
-
*/
|
19
|
-
module.exports = (project, options) => {
|
20
|
-
const {
|
21
|
-
unscopedName,
|
22
|
-
version,
|
23
|
-
description,
|
24
|
-
configFileName,
|
25
|
-
jsRootDir,
|
26
|
-
rootDir,
|
27
|
-
} = project;
|
28
|
-
|
29
|
-
const dockerBin = 'docker';
|
30
|
-
|
31
|
-
const tasks = project.getDockerTargets().map((target) => {
|
32
|
-
const { name, buildFile, buildArgs, isDeprecated, isDefault } = target;
|
33
|
-
|
34
|
-
const suffix = isDefault ? '' : `-${name}`;
|
35
|
-
const targetName = isDefault ? '' : name;
|
36
|
-
|
37
|
-
let repo = target.repo;
|
38
|
-
if (typeof process.env.BUILD_DOCKER_REPO !== 'undefined') {
|
39
|
-
repo = process.env.BUILD_DOCKER_REPO;
|
40
|
-
_log.warn(`Docker repo override specified: [${repo}]`);
|
41
|
-
}
|
42
|
-
|
43
|
-
if (isDeprecated) {
|
44
|
-
_log.warn(
|
45
|
-
'[WARNING] Docker package task configuration is deprecated. Please upgrade to the newer format'
|
46
|
-
);
|
47
|
-
_log.warn(
|
48
|
-
'[WARNING] See: https://github.com/vamship/build-utils#upgrading-to-v03x for more information'
|
49
|
-
);
|
50
|
-
}
|
51
|
-
|
52
|
-
const buildTaskArgs = [
|
53
|
-
'build',
|
54
|
-
'--rm',
|
55
|
-
'--file',
|
56
|
-
buildFile,
|
57
|
-
'--tag',
|
58
|
-
`${repo}:latest`,
|
59
|
-
'--build-arg',
|
60
|
-
`APP_NAME=${unscopedName}`,
|
61
|
-
'--build-arg',
|
62
|
-
`APP_VERSION=${version}`,
|
63
|
-
'--build-arg',
|
64
|
-
`APP_DESCRIPTION='${description}'`,
|
65
|
-
'--build-arg',
|
66
|
-
`CONFIG_FILE_NAME=${configFileName}`,
|
67
|
-
'--build-arg',
|
68
|
-
`BUILD_TIMESTAMP=${Date.now()}`,
|
69
|
-
];
|
70
|
-
|
71
|
-
project.validateRequiredEnv();
|
72
|
-
buildArgs.forEach(({ name, value }) => {
|
73
|
-
buildTaskArgs.push('--build-arg');
|
74
|
-
buildTaskArgs.push(`${name}=${value}`);
|
75
|
-
});
|
76
|
-
|
77
|
-
buildTaskArgs.push('.');
|
78
|
-
|
79
|
-
const buildTask = () =>
|
80
|
-
_execa(dockerBin, buildTaskArgs, {
|
81
|
-
stdio: 'inherit',
|
82
|
-
cwd: jsRootDir.absolutePath,
|
83
|
-
});
|
84
|
-
buildTask.displayName = `package-build${suffix}`;
|
85
|
-
buildTask.description = `Builds a docker image (${targetName}) based on the Dockerfile contained in the project`;
|
86
|
-
|
87
|
-
const tasks = [buildTask];
|
88
|
-
|
89
|
-
if (process.env.BUILD_EXPORT_DOCKER_IMAGE === 'true') {
|
90
|
-
_log.warn(`Docker save image enabled.`);
|
91
|
-
|
92
|
-
const distDir = rootDir.getChild('dist');
|
93
|
-
const savePath = distDir.getFilePath(`image${suffix}.tar`);
|
94
|
-
|
95
|
-
const ensureDirTask = () => {
|
96
|
-
_log.info(
|
97
|
-
`Ensuring that output path exists: ${distDir.absolutePath}`
|
98
|
-
);
|
99
|
-
return _mkdirp(distDir.absolutePath);
|
100
|
-
};
|
101
|
-
ensureDirTask.displayName = `package-save${suffix}`;
|
102
|
-
ensureDirTask.description = `Ensures that destination directory (${savePath}) exists.`;
|
103
|
-
tasks.push(ensureDirTask);
|
104
|
-
|
105
|
-
const saveTask = () => {
|
106
|
-
_log.info(
|
107
|
-
`Docker save enabled. File will be created at: ${savePath}`
|
108
|
-
);
|
109
|
-
return _execa(dockerBin, ['save', '--output', savePath, repo], {
|
110
|
-
stdio: 'inherit',
|
111
|
-
cwd: jsRootDir.absolutePath,
|
112
|
-
});
|
113
|
-
};
|
114
|
-
saveTask.displayName = `package-save${suffix}`;
|
115
|
-
ensureDirTask.description = `Saves a tar file that represents the docker image`;
|
116
|
-
tasks.push(saveTask);
|
117
|
-
}
|
118
|
-
|
119
|
-
const task = _gulp.series(tasks);
|
120
|
-
|
121
|
-
task.displayName = `package${suffix}`;
|
122
|
-
task.description = `Builds a docker image (${targetName}) based on the Dockerfile contained in the project`;
|
123
|
-
|
124
|
-
return task;
|
125
|
-
});
|
126
|
-
|
127
|
-
return tasks;
|
128
|
-
};
|
@@ -1,25 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const { createNpmPackageTask } = require('./utils');
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Sub builder that packages a project using npm pack, from source files or
|
7
|
-
* compiled typescript files.
|
8
|
-
*
|
9
|
-
* @private
|
10
|
-
* @param {Object} project Reference to an object that contains project metadata
|
11
|
-
* that can be used to customize build outputs.
|
12
|
-
* @param {Object} options An options object that can be used to customize the
|
13
|
-
* task.
|
14
|
-
*
|
15
|
-
* @returns {Function} A gulp task.
|
16
|
-
*/
|
17
|
-
module.exports = (project, options) => {
|
18
|
-
const { snakeCasedName, version, rootDir, jsRootDir } = project;
|
19
|
-
|
20
|
-
const packageName = `${snakeCasedName}-${version}.tgz`;
|
21
|
-
const packageDir = jsRootDir;
|
22
|
-
const distDir = rootDir.getChild('dist');
|
23
|
-
|
24
|
-
return createNpmPackageTask(packageDir, packageName, distDir);
|
25
|
-
};
|
@@ -1,54 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const _gulp = require('gulp');
|
4
|
-
const _execa = require('execa');
|
5
|
-
const _path = require('path');
|
6
|
-
const _fs = require('fs');
|
7
|
-
|
8
|
-
const { createNpmPackageTask } = require('./utils');
|
9
|
-
|
10
|
-
/**
|
11
|
-
* Sub builder that packages the types exported by a project using npm pack. A
|
12
|
-
* custom package.json file is generated for the types.
|
13
|
-
*
|
14
|
-
* @private
|
15
|
-
* @param {Object} project Reference to an object that contains project metadata
|
16
|
-
* that can be used to customize build outputs.
|
17
|
-
* @param {Object} options An options object that can be used to customize the
|
18
|
-
* task.
|
19
|
-
*
|
20
|
-
* @returns {Function} A gulp task.
|
21
|
-
*/
|
22
|
-
module.exports = (project, options) => {
|
23
|
-
const { name, snakeCasedName, version, license, keywords, rootDir } =
|
24
|
-
project;
|
25
|
-
|
26
|
-
const packageName = `${snakeCasedName}-types-${version}.tgz`;
|
27
|
-
const packageDir = rootDir
|
28
|
-
.getChild('working')
|
29
|
-
.getChild(project.exportedTypes);
|
30
|
-
const distDir = rootDir.getChild('dist');
|
31
|
-
|
32
|
-
const createPackageJsonTask = (cb) =>
|
33
|
-
_fs.writeFile(
|
34
|
-
packageDir.getFilePath('package.json'),
|
35
|
-
JSON.stringify({
|
36
|
-
name: `${name}-types`,
|
37
|
-
version,
|
38
|
-
description: `Types for project ${name}`,
|
39
|
-
license,
|
40
|
-
keywords,
|
41
|
-
}),
|
42
|
-
cb
|
43
|
-
);
|
44
|
-
createPackageJsonTask.displayName = 'package-types-packagejson';
|
45
|
-
createPackageJsonTask.description =
|
46
|
-
'Creates a package.json file for the types';
|
47
|
-
|
48
|
-
const packTask = createNpmPackageTask(packageDir, packageName, distDir);
|
49
|
-
packTask.displayName = 'package-types-npm';
|
50
|
-
packTask.description =
|
51
|
-
'Creates an NPM package for the types exported by the project';
|
52
|
-
|
53
|
-
return _gulp.series([createPackageJsonTask, packTask]);
|
54
|
-
};
|
@@ -1,50 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const _delete = require('delete');
|
4
|
-
const _execa = require('execa');
|
5
|
-
const _gulp = require('gulp');
|
6
|
-
|
7
|
-
/**
|
8
|
-
* Utility function that initializes and returns an array of tasks for npm
|
9
|
-
* package/publish operations.
|
10
|
-
*
|
11
|
-
* @param {Directory} packageDir The directory in which the package will be
|
12
|
-
* created.
|
13
|
-
* @param {String} packageName The name of the package that is being created.
|
14
|
-
* @param {Directory} targetDir The directory to which the package will be
|
15
|
-
* deployed.
|
16
|
-
*
|
17
|
-
* @returns {Function} A gulp task that creates the package.
|
18
|
-
*/
|
19
|
-
module.exports.createNpmPackageTask = function (
|
20
|
-
packageDir,
|
21
|
-
packageName,
|
22
|
-
targetDir
|
23
|
-
) {
|
24
|
-
const npmBin = 'npm';
|
25
|
-
const args = ['pack'];
|
26
|
-
const packageFile = packageDir.getFileGlob(packageName);
|
27
|
-
|
28
|
-
const packTask = () =>
|
29
|
-
_execa(npmBin, args, {
|
30
|
-
stdio: 'inherit',
|
31
|
-
cwd: packageDir.absolutePath,
|
32
|
-
});
|
33
|
-
|
34
|
-
packTask.displayName = 'package-npm';
|
35
|
-
packTask.description = 'Create a project distribution using npm';
|
36
|
-
|
37
|
-
const copyTask = () =>
|
38
|
-
_gulp.src(packageFile).pipe(_gulp.dest(targetDir.absolutePath));
|
39
|
-
|
40
|
-
copyTask.displayName = 'package-npm-copy';
|
41
|
-
copyTask.description =
|
42
|
-
'Copies the project package to the distribution directory';
|
43
|
-
|
44
|
-
const deleteTask = () => _delete(packageFile);
|
45
|
-
deleteTask.displayName = 'package-npm-delete';
|
46
|
-
deleteTask.description =
|
47
|
-
'Deletes the original packge, leaving just the one in the distribution directory';
|
48
|
-
|
49
|
-
return _gulp.series([packTask, copyTask, deleteTask]);
|
50
|
-
};
|
@@ -1,50 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const _gulp = require('gulp');
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Builder function that can be used to generate a gulp task to publish a
|
7
|
-
* package. The task takes on different implementations based on project types.
|
8
|
-
* For example, javascript libraries will be published to an npm registry, using
|
9
|
-
* `npm publish`, while docker enabled projects will result in a docker image
|
10
|
-
* being published to a docker registry.
|
11
|
-
*
|
12
|
-
* @param {Object} project Reference to an object that contains project metadata
|
13
|
-
* that can be used to customize build outputs.
|
14
|
-
* @param {Object} options An options object that can be used to customize the
|
15
|
-
* task.
|
16
|
-
*
|
17
|
-
* @returns {Function} A gulp task.
|
18
|
-
*/
|
19
|
-
module.exports = (project, options) => {
|
20
|
-
const { types } = options;
|
21
|
-
let createTask = null;
|
22
|
-
|
23
|
-
if (types) {
|
24
|
-
if (!project.hasExportedTypes) {
|
25
|
-
return;
|
26
|
-
}
|
27
|
-
createTask = require('./publish-types');
|
28
|
-
} else if (project.projectType === 'aws-microservice') {
|
29
|
-
createTask = require('./publish-aws');
|
30
|
-
} else if (project.hasDocker) {
|
31
|
-
createTask = require('./publish-docker');
|
32
|
-
} else if (project.projectType === 'lib' || project.projectType === 'cli') {
|
33
|
-
createTask = require('./publish-npm');
|
34
|
-
}
|
35
|
-
|
36
|
-
const task = createTask(project, options);
|
37
|
-
|
38
|
-
if (!(task instanceof Array)) {
|
39
|
-
if (types) {
|
40
|
-
task.displayName = 'publish-types';
|
41
|
-
task.description =
|
42
|
-
'Publish the types exported by this project to a repository';
|
43
|
-
} else {
|
44
|
-
task.displayName = 'publish';
|
45
|
-
task.description = 'Publish the package to a repository';
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
return task;
|
50
|
-
};
|
@@ -1,62 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const _gulp = require('gulp');
|
4
|
-
const _zip = require('gulp-zip');
|
5
|
-
const _execa = require('execa');
|
6
|
-
|
7
|
-
/**
|
8
|
-
* Sub builder that packages an aws-microservice project for deployment. This
|
9
|
-
* follows the build steps described for
|
10
|
-
* [lambda deployments](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-create-deployment-pkg.html#nodejs-package-dependencies)
|
11
|
-
*
|
12
|
-
* @private
|
13
|
-
* @param {Object} project Reference to an object that contains project metadata
|
14
|
-
* that can be used to customize build outputs.
|
15
|
-
* @param {Object} options An options object that can be used to customize the
|
16
|
-
* task.
|
17
|
-
*
|
18
|
-
* @returns {Function} A gulp task.
|
19
|
-
*/
|
20
|
-
module.exports = (project, options) => {
|
21
|
-
const { name, version, rootDir } = project;
|
22
|
-
const infraDir = rootDir.getChild('infra');
|
23
|
-
const workingDir = rootDir.getChild('working');
|
24
|
-
|
25
|
-
const packageName = `${name.replace(/\//g, '-')}-${version}.zip`;
|
26
|
-
|
27
|
-
const cdkBin = 'cdk';
|
28
|
-
|
29
|
-
const tasks = project.getCdkStacks().map((key) => {
|
30
|
-
const envFiles = [
|
31
|
-
infraDir.getFileGlob(`.env.${process.env.INFRA_ENV}`),
|
32
|
-
infraDir.getFileGlob('.env'),
|
33
|
-
];
|
34
|
-
|
35
|
-
const args = [
|
36
|
-
'deploy',
|
37
|
-
project.getCdkStackName(key),
|
38
|
-
'--app',
|
39
|
-
`"node ${workingDir.getFileGlob('infra/index')}"`,
|
40
|
-
];
|
41
|
-
|
42
|
-
if (process.env.INFRA_NO_PROMPT === 'true') {
|
43
|
-
args.splice(1, 0, '--require-approval=never');
|
44
|
-
}
|
45
|
-
|
46
|
-
const task = () => {
|
47
|
-
project.initEnv(envFiles);
|
48
|
-
project.validateRequiredEnv();
|
49
|
-
|
50
|
-
return _execa(cdkBin, args, {
|
51
|
-
stdio: 'inherit',
|
52
|
-
});
|
53
|
-
};
|
54
|
-
|
55
|
-
task.displayName = `publish-${key}`;
|
56
|
-
task.description = `Publishes the ${key} stack to AWS using CDK`;
|
57
|
-
|
58
|
-
return task;
|
59
|
-
});
|
60
|
-
|
61
|
-
return tasks;
|
62
|
-
};
|
@@ -1,79 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const _execa = require('execa');
|
4
|
-
const _gulp = require('gulp');
|
5
|
-
const _log = require('fancy-log');
|
6
|
-
const _semver = require('semver');
|
7
|
-
|
8
|
-
/**
|
9
|
-
* Sub builder that builds a docker image based on a predefined dockerfile.
|
10
|
-
*
|
11
|
-
* @private
|
12
|
-
* @param {Object} project Reference to an object that contains project metadata
|
13
|
-
* that can be used to customize build outputs.
|
14
|
-
* @param {Object} options An options object that can be used to customize the
|
15
|
-
* task.
|
16
|
-
*
|
17
|
-
* @returns {Function} A gulp task.
|
18
|
-
*/
|
19
|
-
module.exports = (project, options) => {
|
20
|
-
const { version } = project;
|
21
|
-
|
22
|
-
const dockerBin = 'docker';
|
23
|
-
const major = _semver.major(version);
|
24
|
-
const minor = _semver.minor(version);
|
25
|
-
|
26
|
-
const tasks = project.getDockerTargets().map((target) => {
|
27
|
-
const { name, isDefault, isDeprecated } = target;
|
28
|
-
const { latestOnly } = options;
|
29
|
-
|
30
|
-
let repo = target.repo;
|
31
|
-
if (typeof process.env.BUILD_DOCKER_REPO !== 'undefined') {
|
32
|
-
repo = process.env.BUILD_DOCKER_REPO;
|
33
|
-
_log.warn(`Docker repo override specified: [${repo}]`);
|
34
|
-
}
|
35
|
-
|
36
|
-
let suffix = `${isDefault ? '' : '-name'}${
|
37
|
-
latestOnly ? '-latest' : ''
|
38
|
-
}`;
|
39
|
-
|
40
|
-
const tagList = latestOnly
|
41
|
-
? ['latest']
|
42
|
-
: [version, major, `${major}.${minor}`];
|
43
|
-
|
44
|
-
const tags = tagList.map((tag) => `${repo}:${tag}`);
|
45
|
-
const latestTag = `${repo}:latest`;
|
46
|
-
|
47
|
-
const tasks = tags.map((tag) => {
|
48
|
-
const tagTask = () =>
|
49
|
-
_execa(dockerBin, ['tag', latestTag, tag], {
|
50
|
-
stdio: 'inherit',
|
51
|
-
});
|
52
|
-
tagTask.displayName = `publish-docker-tag-${tag}${suffix}`;
|
53
|
-
tagTask.description = `Tag image with ${tag} (${name})`;
|
54
|
-
|
55
|
-
const pushTask = () =>
|
56
|
-
_execa(dockerBin, ['push', tag], {
|
57
|
-
stdio: 'inherit',
|
58
|
-
});
|
59
|
-
pushTask.displayName = `publish-docker-push-${tag}${suffix}`;
|
60
|
-
pushTask.description = `Publish docker image with ${tag} (${name}) to registry`;
|
61
|
-
|
62
|
-
const task = _gulp.series([tagTask, pushTask]);
|
63
|
-
task.displayName = `publish-docker-${tag}${suffix}`;
|
64
|
-
task.description = `Tag and push image with ${tag} (${name})`;
|
65
|
-
|
66
|
-
return task;
|
67
|
-
});
|
68
|
-
|
69
|
-
const task = _gulp.parallel(tasks);
|
70
|
-
task.displayName = `publish${suffix}`;
|
71
|
-
task.description = latestOnly
|
72
|
-
? `Tags image ${name} with latest tag and pushes to registry`
|
73
|
-
: `Tags image ${name} with version tags, and pushes to registry`;
|
74
|
-
|
75
|
-
return task;
|
76
|
-
});
|
77
|
-
|
78
|
-
return tasks;
|
79
|
-
};
|
@@ -1,36 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const _gulp = require('gulp');
|
4
|
-
const _execa = require('execa');
|
5
|
-
|
6
|
-
/**
|
7
|
-
* Sub builder that publishes a project using npm publish.
|
8
|
-
*
|
9
|
-
* @private
|
10
|
-
* @param {Object} project Reference to an object that contains project metadata
|
11
|
-
* that can be used to customize build outputs.
|
12
|
-
* @param {Object} options An options object that can be used to customize the
|
13
|
-
* task.
|
14
|
-
*
|
15
|
-
* @returns {Function} A gulp task.
|
16
|
-
*/
|
17
|
-
module.exports = (project, options) => {
|
18
|
-
const { snakeCasedName, version, rootDir } = project;
|
19
|
-
|
20
|
-
const packageName = `${snakeCasedName}-${version}.tgz`;
|
21
|
-
|
22
|
-
const npmBin = 'npm';
|
23
|
-
const args = ['publish', packageName];
|
24
|
-
|
25
|
-
const publishTask = () =>
|
26
|
-
_execa(npmBin, args, {
|
27
|
-
stdio: 'inherit',
|
28
|
-
cwd: rootDir.getChild('dist').absolutePath,
|
29
|
-
});
|
30
|
-
|
31
|
-
publishTask.displayName = 'publish-npm';
|
32
|
-
publishTask.description =
|
33
|
-
'Publish an existing package to an npm repository';
|
34
|
-
|
35
|
-
return _gulp.parallel(publishTask);
|
36
|
-
};
|
@@ -1,36 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const _gulp = require('gulp');
|
4
|
-
const _execa = require('execa');
|
5
|
-
|
6
|
-
/**
|
7
|
-
* Sub builder that publishes a project using npm publish.
|
8
|
-
*
|
9
|
-
* @private
|
10
|
-
* @param {Object} project Reference to an object that contains project metadata
|
11
|
-
* that can be used to customize build outputs.
|
12
|
-
* @param {Object} options An options object that can be used to customize the
|
13
|
-
* task.
|
14
|
-
*
|
15
|
-
* @returns {Function} A gulp task.
|
16
|
-
*/
|
17
|
-
module.exports = (project, options) => {
|
18
|
-
const { snakeCasedName, version, rootDir } = project;
|
19
|
-
|
20
|
-
const packageName = `${snakeCasedName}-types-${version}.tgz`;
|
21
|
-
|
22
|
-
const npmBin = 'npm';
|
23
|
-
const args = ['publish', packageName];
|
24
|
-
|
25
|
-
const publishTask = () =>
|
26
|
-
_execa(npmBin, args, {
|
27
|
-
stdio: 'inherit',
|
28
|
-
cwd: rootDir.getChild('dist').absolutePath,
|
29
|
-
});
|
30
|
-
|
31
|
-
publishTask.displayName = 'publish-npm-types';
|
32
|
-
publishTask.description =
|
33
|
-
'Publish an existing package to an npm repository';
|
34
|
-
|
35
|
-
return _gulp.parallel([publishTask]);
|
36
|
-
};
|
@@ -1,39 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const _gulp = require('gulp');
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Builder function that can be used to generate a gulp task to execute
|
7
|
-
* instrumented unit/api tests.
|
8
|
-
*
|
9
|
-
* @param {Object} project Reference to an object that contains project metadata
|
10
|
-
* that can be used to customize build outputs.
|
11
|
-
* @param {Object} options An options object that can be used to customize the
|
12
|
-
* task.
|
13
|
-
*
|
14
|
-
* @returns {Function} A gulp task.
|
15
|
-
*/
|
16
|
-
module.exports = (project, options) => {
|
17
|
-
const { testType, watch } = Object.assign(
|
18
|
-
{ testType: 'unit', watch: false },
|
19
|
-
options
|
20
|
-
);
|
21
|
-
const tasks = [];
|
22
|
-
if (project.projectType !== 'ui') {
|
23
|
-
const nonUiTests = require('./test');
|
24
|
-
tasks.push(nonUiTests(project, options));
|
25
|
-
} else {
|
26
|
-
const uiTests = require('./test-ui');
|
27
|
-
tasks.push(uiTests(project, options));
|
28
|
-
}
|
29
|
-
const task = _gulp.parallel(tasks);
|
30
|
-
if (!watch) {
|
31
|
-
task.displayName = `test-${testType}`;
|
32
|
-
task.description = `Execute ${testType} tests`;
|
33
|
-
} else {
|
34
|
-
task.displayName = `watch-test-${testType}`;
|
35
|
-
task.description = `Automatically execute ${testType} tests on change`;
|
36
|
-
}
|
37
|
-
|
38
|
-
return task;
|
39
|
-
};
|