in aws_lambda_builders/workflows/nodejs_npm/workflow.py [0:0]
def actions_without_bundler(self, source_dir, artifacts_dir, scratch_dir, manifest_path, osutils, subprocess_npm):
"""
Generate a list of Nodejs build actions without a bundler
:type source_dir: str
:param source_dir: an existing (readable) directory containing source files
:type artifacts_dir: str
:param artifacts_dir: an existing (writable) directory where to store the output.
:type scratch_dir: str
:param scratch_dir: an existing (writable) directory for temporary files
:type manifest_path: str
:param manifest_path: path to package.json of an NPM project with the source to pack
:type osutils: aws_lambda_builders.workflows.nodejs_npm.utils.OSUtils
:param osutils: An instance of OS Utilities for file manipulation
:type subprocess_npm: aws_lambda_builders.workflows.nodejs_npm.npm.SubprocessNpm
:param subprocess_npm: An instance of the NPM process wrapper
:rtype: list
:return: List of build actions to execute
"""
tar_dest_dir = osutils.joinpath(scratch_dir, "unpacked")
tar_package_dir = osutils.joinpath(tar_dest_dir, "package")
npm_pack = NodejsNpmPackAction(
tar_dest_dir, scratch_dir, manifest_path, osutils=osutils, subprocess_npm=subprocess_npm
)
npm_copy_npmrc = NodejsNpmrcCopyAction(tar_package_dir, source_dir, osutils=osutils)
actions = [
npm_pack,
npm_copy_npmrc,
CopySourceAction(tar_package_dir, artifacts_dir, excludes=self.EXCLUDED_FILES),
]
if self.download_dependencies:
# installed the dependencies into artifact folder
actions.append(NodejsNpmInstallAction(artifacts_dir, subprocess_npm=subprocess_npm))
# if dependencies folder exists, copy or move dependencies from artifact folder to dependencies folder
# depends on the combine_dependencies flag
if self.dependencies_dir:
# clean up the dependencies folder first
actions.append(CleanUpAction(self.dependencies_dir))
# if combine_dependencies is set, we should keep dependencies and source code in the artifact folder
# while copying the dependencies. Otherwise we should separate the dependencies and source code
if self.combine_dependencies:
actions.append(CopyDependenciesAction(source_dir, artifacts_dir, self.dependencies_dir))
else:
actions.append(MoveDependenciesAction(source_dir, artifacts_dir, self.dependencies_dir))
else:
# if dependencies folder exists and not download dependencies, simply copy the dependencies from the
# dependencies folder to artifact folder
if self.dependencies_dir and self.combine_dependencies:
actions.append(CopySourceAction(self.dependencies_dir, artifacts_dir))
else:
LOG.info(
"download_dependencies is False and dependencies_dir is None. Copying the source files into the "
"artifacts directory. "
)
actions.append(NodejsNpmrcCleanUpAction(artifacts_dir, osutils=osutils))
actions.append(NodejsNpmLockFileCleanUpAction(artifacts_dir, osutils=osutils))
if self.dependencies_dir:
actions.append(NodejsNpmLockFileCleanUpAction(self.dependencies_dir, osutils=osutils))
return actions