Skip to content

Commit

Permalink
Include CDM in external folder via manifest file
Browse files Browse the repository at this point in the history
  • Loading branch information
czmj committed Sep 5, 2022
1 parent c775fe5 commit 3b2dc22
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
1 change: 1 addition & 0 deletions external/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hpc_cdm
9 changes: 9 additions & 0 deletions external/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: 'Setup External Repos'
description: 'Clone repositories specified in manifest file'
author: 'Sam Lanning <[email protected]>'
runs:
using: 'node16'
main: 'setup.js'
branding:
icon: 'download-cloud'
color: 'purple'
7 changes: 7 additions & 0 deletions external/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"path": "hpc_cdm",
"url": "https://github.com/UN-OCHA/hpc-cdm.git",
"ref": "develop"
}
]
47 changes: 47 additions & 0 deletions external/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// @ts-check

const child_process = require('child_process');
const path = require('path');
const { promises: { stat }} = require('fs');
const { promisify } = require('util');

const manifest = require('./manifest.json');

const exec = promisify(child_process.exec);

(async () => {

for (const entry of manifest) {
const p = path.resolve(__dirname, entry.path);
console.log(`Setting up external repo ${p}`);

const exists = await stat(p).then(() => true).catch(() => false);
if (!exists) {
// Clone repository
const clone = await exec(`git clone "${entry.url}" "${p}"`);
console.log(clone.stderr);
console.log(clone.stdout);
}

// Fetch desired commit
const fetch = await exec(
`git fetch origin ${entry.ref}`,
{
cwd: p
}
);
console.log(fetch.stderr);
console.log(fetch.stdout);

// Fetch desired commit
const checkout = await exec(
`git checkout ${entry.ref}`,
{
cwd: p
}
);
console.log(checkout.stderr);
console.log(checkout.stdout);
}

})();
6 changes: 5 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
"esModuleInterop": true,
"skipLibCheck": true,
"strictPropertyInitialization": false,
"strict": true
"strict": true,
"baseUrl": "external/hpc_cdm",
"paths": {
"@unocha/hpc-data": ["libs/hpc-data/src/"],
}
},
"include": ["src/**/*.ts", "src/**/*.js", "start.js", "bin"],
"exclude": ["node_modules"]
Expand Down

0 comments on commit 3b2dc22

Please sign in to comment.