diff --git a/external/.gitignore b/external/.gitignore new file mode 100644 index 00000000..dd9cb3af --- /dev/null +++ b/external/.gitignore @@ -0,0 +1 @@ +hpc_cdm \ No newline at end of file diff --git a/external/action.yml b/external/action.yml new file mode 100644 index 00000000..aa02569a --- /dev/null +++ b/external/action.yml @@ -0,0 +1,9 @@ +name: 'Setup External Repos' +description: 'Clone repositories specified in manifest file' +author: 'Sam Lanning ' +runs: + using: 'node16' + main: 'setup.js' +branding: + icon: 'download-cloud' + color: 'purple' diff --git a/external/manifest.json b/external/manifest.json new file mode 100644 index 00000000..ea678787 --- /dev/null +++ b/external/manifest.json @@ -0,0 +1,7 @@ +[ + { + "path": "hpc_cdm", + "url": "https://github.com/UN-OCHA/hpc-cdm.git", + "ref": "develop" + } +] diff --git a/external/setup.js b/external/setup.js new file mode 100644 index 00000000..71315c64 --- /dev/null +++ b/external/setup.js @@ -0,0 +1,43 @@ +// @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); + } +})(); diff --git a/tsconfig.json b/tsconfig.json index 4170157e..4a6f5f7d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,8 +15,18 @@ "esModuleInterop": true, "skipLibCheck": true, "strictPropertyInitialization": false, - "strict": true + "strict": true, + "baseUrl": "external/hpc_cdm", + "paths": { + "@unocha/hpc-core": ["libs/hpc-core/src/"], + "@unocha/hpc-data": ["libs/hpc-data/src/"], + "@unocha/hpc-live/lib/model": ["libs/hpc-live/src/lib/model"] + } }, - "include": ["src/**/*.ts", "src/**/*.js", "start.js", "bin"], - "exclude": ["node_modules"] + "include": ["src/**/*.ts", "src/**/*.js", "start.js", "bin", "external"], + "exclude": [ + "node_modules", + "external/hpc_cdm/node_modules", + "external/hpc_cdm/tmp" + ] }