Browse Source

Make the build work on windows and everywhere else with a special version of the needs_prod_media target just for windows.

master
Zed A. Shaw 3 months ago
parent
commit
1f01a4413f
3 changed files with 39 additions and 5 deletions
  1. +1
    -1
      ci.config.js
  2. +1
    -1
      package.json
  3. +37
    -3
      scripts/services/ci.js

+ 1
- 1
ci.config.js View File

@@ -17,7 +17,7 @@ exports.development = {
exports.staging = {
private: '../ljsthw-private/',
testing_target: 'deployment/testing',
build_target: 'deployment/production',
build_target: 'deployment/staging',
deploy_target: '/mnt/www/share',
fixtures: '__tests__/fixtures',
gzip_filter: ['!index.html', '*.css', '*.js', '*.html', '*.svg', '*.json'],


+ 1
- 1
package.json View File

@@ -12,7 +12,7 @@
"fixtures": "rm -rf deployment/testing/* protected && ln -sf ./deployment/testing protected && ./scripts/rr ./scripts/services/generator.js --debug -s __tests__/fixtures -t protected",
"testwatch": "NODE_OPTIONS='--unhandled-rejections=strict' jest --watch --notify --detectOpenHandles",
"deploy": "npx sapper export && rsync -azzv __sapper__/export/ $DEP_USER@learnjsthehardway.com:/srv/http/www/learnjsthehardway.com/",
"staging": "./scripts/rr ./scripts/services/ci.js --debug --force --production --not_needed=prod_code,www_push,restart --build_target=deployment/staging"
"staging": "node scripts/rr ./scripts/services/ci.js --debug --force --production --not_needed=git_logs,prod_code,www_push,restart --build_target=deployment/staging"
},
"dependencies": {
"Validator": "^1.1.1",


+ 37
- 3
scripts/services/ci.js View File

@@ -10,6 +10,8 @@ const waitOn = require('wait-on');
const assert = require('assert');
const simpleGit = require('simple-git/promise');
const config = require('../../ci.config')[secrets.env];
const os = require("os");
const path = require("path");

const pm2_do = (action, name) => {
log.debug(`Restarting the ${name} process.`);
@@ -97,9 +99,42 @@ exports.needs_npm_update = build.rule('needs npm update', {
}
});

exports.needs_prod_media_windows = build.rule('needs production media on windows', {
when: [
f => f.force || f.git_db_updated || f.git_code_updated,
f => !f.prod_media_ready,
f => os.platform() === 'win32'
],
then: async f => {
log.info(`DB update ${f.git_db_updated} or CODE update ${f.git_code_updated}, building media.`);
log.debug('Linking in the new content');

// need to make sure the production dir is there
build.mkdir('protected');
build.mkdir(config.build_target);

const private_media = path.normalize(`${config.private}/media`);
const target_media = path.normalize(`${config.build_target}/media`);

build.mkdir(target_media);

// use rsync to bring over any media from the private repo
build.exec(`xcopy /D /E ${private_media} ${target_media}`);

await rr.run('./scripts/services/generator', {source: config.private, target: config.build_target});

build.exec(`xcopy /D /E ${target_media}\\..\\* protected\\`);

f.prod_media_ready = true;
}
});

exports.needs_prod_media = build.rule('needs production media', {
when: [f => f.force || f.git_db_updated || f.git_code_updated, f => !f.prod_media_ready],
when: [
f => f.force || f.git_db_updated || f.git_code_updated,
f => !f.prod_media_ready,
f => os.platform() !== 'win32'
],
then: async f => {
log.info(`DB update ${f.git_db_updated} or CODE update ${f.git_code_updated}, building media.`);
log.debug('Linking in the new content');
@@ -108,7 +143,7 @@ exports.needs_prod_media = build.rule('needs production media', {
}

// need to make sure the production dir is there
build.mkdir(config.build_target);
build.mkdir(config.build_target);

log.debug(`Creating symlink protected to ${config.build_target}`);
await fs.symlink(config.build_target, 'protected');
@@ -230,4 +265,3 @@ exports.failure = async (error, facts) => {
log.info("Not sending email. Add --send_email to enable it.");
}
}


Loading…
Cancel
Save