in packages/@aws-cdk-testing/cli-integ/lib/cli/stage-distribution.ts [14:149]
async function main() {
await yargs
.usage('$0 <command>')
.option('npm', {
description: 'Upload NPM packages only',
type: 'boolean',
requiresArg: false,
})
.option('python', {
description: 'Upload Python packages only',
type: 'boolean',
requiresArg: false,
})
.option('java', {
description: 'Upload Java packages only',
type: 'boolean',
requiresArg: false,
})
.option('dotnet', {
description: 'Upload Dotnet packages only',
type: 'boolean',
requiresArg: false,
})
.option('regression', {
description: 'Enable access to previous versions of the staged packages (this is expensive for CodeArtifact so we only do it when necessary)',
type: 'boolean',
requiresArg: false,
default: false,
})
.command('publish <DIRECTORY>', 'Publish a given directory', cmd => cmd
.positional('DIRECTORY', {
descripton: 'Directory distribution',
type: 'string',
demandOption: true,
})
.option('name', {
alias: 'n',
description: 'Name of the repository to create (default: generate unique name)',
type: 'string',
requiresArg: true,
}), async (args) => {
await validateDirectory(args);
const repo = await (args.name ? TestRepository.newWithName(args.name) : TestRepository.newRandom());
const usageDir = UsageDir.default();
await doLogin(repo, usageDir, args);
await publish(repo, usageDir, args);
header('Done');
usageDir.advertise();
})
.command('login', 'Login to a given repository', cmd => cmd
.option('name', {
alias: 'n',
description: 'Name of the repository to log in to',
type: 'string',
requiresArg: true,
demandOption: true,
}), async (args) => {
const repo = TestRepository.existing(args.name);
const usageDir = UsageDir.default();
await doLogin(repo, usageDir, args);
usageDir.advertise();
})
.command('run <DIRECTORY> <COMMAND..>', 'Publish and run a command', cmd => cmd
.positional('DIRECTORY', {
descripton: 'Directory distribution',
type: 'string',
demandOption: true,
})
.positional('COMMAND', {
alias: 'c',
description: 'Run the given command with the packages staged',
type: 'string',
array: true,
demandOption: true,
})
.option('cleanup', {
alias: 'C',
description: 'Cleanup the repository afterwards',
type: 'boolean',
default: true,
requiresArg: false,
}), async (args) => {
await validateDirectory(args);
const repo = await TestRepository.newRandom();
const usageDir = UsageDir.default();
await doLogin(repo, usageDir, args);
await publish(repo, usageDir, args);
try {
await usageDir.activateInCurrentProcess();
await shell(args.COMMAND ?? [], {
shell: true,
show: 'always',
});
} finally {
if (args.cleanup) {
await repo.delete();
}
}
})
.command('cleanup', 'Clean up testing repository', cmd => cmd
.option('name', {
alias: 'n',
description: 'Name of the repository to cleanup (default: most recent)',
type: 'string',
requiresArg: true,
}), async (args) => {
const usageDir = UsageDir.default();
let repositoryName = args.name;
if (!repositoryName) {
repositoryName = (await usageDir.currentEnv()).CODEARTIFACT_REPO;
}
if (!repositoryName) {
console.log(`No --name given and no $CODEARTIFACT_REPO found in ${usageDir.directory}, nothing cleaned up`);
return;
}
const repo = TestRepository.existing(repositoryName);
await repo.delete();
})
.command('gc', 'Clean up day-old testing repositories', cmd => cmd, async () => {
await TestRepository.gc();
})
.demandCommand(1, 'You must supply a command')
.help()
.showHelpOnFail(false)
.parse();
}