Migrate Webtasks between deployments
Usage
const { Token, TokenStore, Deployment, WebtaskAnalyzer } = require('webtask-migrate');
const tenantTokenString = process.env.TENANT_TOKEN;
const fromDeploymentUrl = process.env.FROM_DEPLOYMENT_URL;
const toDeploymentUrl = process.env.TO_DEPLOYMENT_URL;
const tenantName = process.env.TENANT_NAME;
const webtaskName = process.env.WEBTASK_NAME;
const tokenStore = new TokenStore();
tokenStore.addToken(new Token(tenantTokenString));
const fromDeployment = new Deployment(tokenStore, fromDeploymentUrl);
const toDeployment = new Deployment(tokenStore, toDeploymentUrl);
const webtaskAnalyzer = new WebtaskAnalyzer(fromDeployment, tenantName);
const downloadOptions = {
includeCron: true,
includeStorage: true,
includeSecrets: true
};
const webtask = await fromDeployment.downloadWebtask(tenantName, webtaskName, downloadOptions);
const analysis = await webtaskAnalyzer.analyze(webtaskName, webtask);
webtask.addDependencies(analysis.dependencies);
await toDeployment.provisionModules(webtask.getDependencies(), tenantName);
await toDeployment.uploadWebtask(tenantName, webtaskName, webtask);
console.log(analysis.warnings)
See the samples folder for examples that provide batch processing of webtasks migration