From d01e0646b7122c2aebacc24961dc22ca1f0f0118 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Tue, 12 Jul 2022 15:02:29 -0500 Subject: [PATCH] wip(core-styles): fp-1499 fractal custom build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Status (Fail): ``` Core-CMS git:(task/fp-1499-cms-pattern-library) ✗ npm run build:demo > @tacc/core-cms@3.7.11 build:demo > fractal build-project $npm_config_project Warning: command named "info" was registered more than once. If you intend to override a command, you should explicitly remove the first command with command.remove(). [...] ``` --- fractal.config.js | 40 +++++++++++++++++++++++++++++----------- package.json | 2 +- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/fractal.config.js b/fractal.config.js index 6e94a4790..02c804a35 100644 --- a/fractal.config.js +++ b/fractal.config.js @@ -1,18 +1,10 @@ 'use strict'; -const fs = require('fs'); const path = require('path'); const mandelbrot = require('@frctl/mandelbrot'); -const minimist = require('minimist'); const { getStaticFilePath } = require( __dirname + '/bin/get-path.js'); -const args = minimist( process.argv.slice( 2 ) ); -let projectName = args['project'] || ''; - projectName = ( projectName !== 'core-cms' ) ? projectName : ''; -const projectCSSFile = projectName - ? getStaticFilePath( projectName, 'css/build/site.css') - : null; const fractal = require('@tacc/core-styles/fractal.config.js'); const themeConfig = require('@tacc/core-styles/fractal.theme.js'); @@ -38,13 +30,39 @@ fractal.components.set('default.context', { global: [ 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css', '/static/site_cms/css/build/site.css' - ].concat( - ( projectCSSFile ) ? [ '/' + projectCSSFile ] : [] - ) + ] } } }); + + +fractal.cli.command( + 'build-project [project]', + function buildProject( args, done ) { + // The Core site is named 'core-cms', but its Python app name is 'site_cms' + const coreName = 'site_cms'; + let projName = args.project || coreName; + projName = ( projName === 'core-cms' ) ? coreName : projName; + + const context = this.fractal.components.get('default.context'); + const projCSSFile = getStaticFilePath( projName, 'css/build/site.css'); + + if ( projName ) { + context.styles.external.global.push( projCSSFile ); + } + this.fractal.components.set('default.context', context); + + this.fractal.cli.exec('build'); + + done(); + }, { + description: 'Lists components in the project' + } +); + + + fractal.web.set('static.path', path.join(coreStylesRoot, 'dist') ); diff --git a/package.json b/package.json index cacef1daa..5b36aaf66 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "scripts": { "build": "npm run build:css && npm run build:demo", "build:css": "bin/build-css.js --project=$npm_config_project --build-id=$npm_config_build_id", - "build:demo": "fractal build --project=$npm_config_project" + "build:demo": "fractal build-project $npm_config_project" }, "homepage": "https://github.com/TACC/Core-CMS" }