Browse Source

New the deploy command mostly works, but it's specific to each deployment.

master
Zed A. Shaw 2 months ago
parent
commit
a95e84fa76
  1. 49
      commands/deploy.js
  2. 2
      lib/builderator.js

49
commands/deploy.js

@ -1,39 +1,40 @@
import { glob, rm, changed, mkdir, exec_i, exec } from "../lib/builderator.js";
import { glob, changed, exec_i } from "../lib/builderator.js";
export const description = "NOT WORKING. Deploys new changes to the app.";
export const description = "Deploys new changes to the app.";
export const options = [
['--env <string>', 'Deploy using which environment prod/staging.'],
['--dry-run', "Don't actually update, just pretend."]
];
const config = {
source_dir: "../ljsthw-private"
};
export const main = (opts) => {
const cwd = process.cwd();
exec_i("git pull");
const dry_run = opts.dryRun ? "--dry-run" : "";
process.chdir(config.source_dir);
exec_i("git pull");
process.chdir(cwd);
// // run the builds
exec_i("npm run knex migrate:latest");
exec_i("npm run build");
exec_i("node ./bando.js rendered");
exec_i("git pull");
const ext_list = ["html", "css", "js", "svg", "xml", "md"];
// // run the builds
// exec("npm run knex migrate:latest");
// exec("npm run build");
// exec("npm run rendered");
// exec("npm run modules");
for(let ext of ext_list) {
const files = glob(`./public/**/*.${ext}`);
const ext_list = ["html", "css", "js", "svg", "xml", "md"];
for(let fname of files) {
if(changed(fname, `${fname}.br`)) {
// compress the files with brotli
exec_i(`brotli -Zfk "${fname}"`);
}
for(let ext of ext_list) {
const files = glob(`./public/**/*.${ext}`);
// compress the files with brotli
console.log(files);
// compress the files with gzip
if(changed(fname, `${fname}.gz`)) {
exec_i(`gzip -9fk "${fname}"`);
}
}
}
// sync the files
exec_i(`rsync ${dry_run} -av --exclude media --delete public/* /var/www/`);
// sync the files
// exec("rsync -av --exclude media --delete public/* /var/www/learnjsthehardway.com/");
process.exit(0);
}

2
lib/builderator.js

@ -97,7 +97,7 @@ export const index_rollup = (src_index, target_index, contents, key) => {
}
export const exec = (cmd, opts) => {
log.info("EXEC", cmd, opts || '');
log.info(`EXEC ${cmd}`);
return execSync(cmd, opts);
}

Loading…
Cancel
Save