From b67176431b89bc87eb068c92884f7fc54fc02d05 Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Wed, 13 Dec 2023 13:07:48 +0100 Subject: [PATCH] Removed manual list of Typescript projects from dev script fixes https://github.com/TryGhost/DevOps/issues/122 - this introduces some code to get all the Typescript projects programatically instead of relying on developers to manually add their project to the list, which is clearly better --- .github/scripts/dev.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/scripts/dev.js b/.github/scripts/dev.js index f5974f3965..ad6f3b02af 100644 --- a/.github/scripts/dev.js +++ b/.github/scripts/dev.js @@ -1,3 +1,4 @@ +const fs = require('fs'); const path = require('path'); const util = require('util'); const exec = util.promisify(require('child_process').exec); @@ -16,6 +17,20 @@ const config = require('../../ghost/core/core/shared/config/loader').loadNconf({ customConfigPath: path.join(__dirname, '../../ghost/core') }); +const tsPackages = fs.readdirSync(path.resolve(__dirname, '../../ghost'), {withFileTypes: true}) + .filter(dirent => dirent.isDirectory()) + .map(dirent => dirent.name) + .filter(packageFolder => { + try { + const packageJson = require(path.resolve(__dirname, `../../ghost/${packageFolder}/package.json`)); + return packageJson.scripts?.['build:ts']; + } catch (err) { + return false; + } + }) + .map(packageFolder => `ghost/${packageFolder}`) + .join(','); + const liveReloadBaseUrl = config.getSubdir() || '/ghost/'; const siteUrl = config.getSiteUrl(); @@ -45,7 +60,7 @@ const COMMAND_ADMIN = { const COMMAND_TYPESCRIPT = { name: 'ts', - command: 'while [ 1 ]; do nx watch --projects=ghost/collections,ghost/in-memory-repository,ghost/bookshelf-repository,ghost/mail-events,ghost/model-to-domain-event-interceptor,ghost/post-revisions,ghost/nql-filter-expansions,ghost/post-events,ghost/donations,ghost/recommendations,ghost/email-addresses -- nx run \\$NX_PROJECT_NAME:build:ts; done', + command: `while [ 1 ]; do nx watch --projects=${tsPackages} -- nx run \\$NX_PROJECT_NAME:build:ts; done`, cwd: path.resolve(__dirname, '../../'), prefixColor: 'cyan', env: {}