-
Notifications
You must be signed in to change notification settings - Fork 1
Add template files for hf. #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,16 +20,21 @@ async function promptForConfig() { | |
| { | ||
| type: 'checkbox', | ||
| name: 'additionalFeatures', | ||
| message: 'What additional features does your app require', | ||
| message: 'What additional features does your app require (these are checkboxes)', | ||
| default: ['electric-flow', 'header-footer'], | ||
| choices: [ | ||
| { | ||
| name: 'Using a shared Polymer Component within your React App?', | ||
| value: 'polymer', | ||
| }, | ||
| { | ||
| name: `Configure app for Electric Flow`, | ||
| value: 'electric-flow', | ||
| }, | ||
| { | ||
| name: `Include hf (header/footer)`, | ||
| value: 'header-footer', | ||
| }, | ||
| { | ||
| name: 'Using a shared Polymer Component within your React App?', | ||
| value: 'polymer', | ||
| }, | ||
| ], | ||
| }, | ||
| ]; | ||
|
|
@@ -48,6 +53,9 @@ function installFrontierDependencies(appPath, answers, useYarn, ownPath) { | |
| if (additionalFeatures.includes('electric-flow')) { | ||
| configureEF(appPath, useYarn, ownPath); | ||
| } | ||
| if (additionalFeatures.includes('header-footer')) { | ||
| configureHF(appPath, useYarn, ownPath); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not specific to hf, but I don't think we should allow yarn as an option There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with that I guess, but if a developer doesn't use the --use-npm option, then they'll get react, react-dom, and @fs/react-scripts installed with yarn, and then all of "our" dependencies installed with npm. I don't know if anyone would ever use create-react-app that way though, they should just use the fr-cli. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll go ahead and make this change to remove the yarn option completely in our frontierInit code |
||
| } | ||
| injectPolymerCode(appPath); | ||
|
|
||
| const defaultModules = ['http-proxy-middleware@0.19.0', 'fs-webdev/exo']; | ||
|
|
@@ -127,6 +135,40 @@ function configureEF(appPath, useYarn, ownPath) { | |
|
|
||
| const templatePath = path.join(ownPath, 'template-ef'); | ||
| fs.copySync(templatePath, appPath, { overwrite: true }); | ||
|
|
||
| alterPackageJsonFile(appPath, appPackage => { | ||
| const packageJson = { ...appPackage }; | ||
| const additionalScripts = { | ||
| "heroku-prebuild": "./heroku-prebuild.sh" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we put this file in a common location instead of copying into each app? |
||
| }; | ||
| packageJson.scripts = sortScripts({ ...packageJson.scripts, ...additionalScripts }); | ||
| return packageJson; | ||
| }); | ||
| } | ||
|
|
||
| function configureHF(appPath, useYarn, ownPath) { | ||
|
|
||
| const templatePath = path.join(ownPath, 'template-hf'); | ||
| fs.copySync(templatePath, appPath, { overwrite: true }); | ||
|
|
||
| alterPackageJsonFile(appPath, appPackage => { | ||
| const packageJson = { ...appPackage }; | ||
| const additionalScripts = { | ||
| "build:prod": "PUBLIC_URL=https://edge.fscdn.org/assets/ react-scripts build", | ||
| "heroku-postbuild": "npm run build:prod" | ||
| }; | ||
| packageJson.scripts = sortScripts({ ...packageJson.scripts, ...additionalScripts }); | ||
| packageJson.main = "./server.js"; | ||
|
|
||
| return packageJson; | ||
| }); | ||
|
|
||
| let modules = [ | ||
| 'github:fs-webdev/hf#cra', | ||
| 'github:fs-webdev/snow#cra', | ||
| 'github:fs-webdev/startup', | ||
| ] | ||
| installModulesSync(modules, useYarn); | ||
| } | ||
|
|
||
| function cleanupFrontierCode(appPath) {} | ||
|
|
@@ -154,3 +196,11 @@ function buildInstallCommandAndArgs(useYarn, saveDev = false) { | |
| } | ||
| return { command, args }; | ||
| } | ||
|
|
||
| function sortScripts(scripts){ | ||
| const sortedScripts = {}; | ||
| Object.keys(scripts).sort().forEach(function(key) { | ||
| sortedScripts[key] = scripts[key]; | ||
| }); | ||
| return sortedScripts; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| https://github.com/heroku/heroku-buildpack-nodejs.git | ||
| https://github.com/fs-webdev/heroku-buildpack-upload-static-assets-to-s3.git |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #!/bin/bash | ||
|
|
||
| if [ "$NODE_ENV" == "production" ]; then | ||
| echo "-----> Building .npmrc and .netrc" | ||
|
|
||
| echo "//code.lds.org/artifactory/api/npm/npm-fhd/:_authToken=${NPM_TOKEN}" > .npmrc | ||
| echo "@fs:registry=https://code.lds.org/artifactory/api/npm/npm-fhd/" >> .npmrc | ||
| echo -e "machine github.com\n login $GITHUB_AUTH_TOKEN" > ~/.netrc | ||
| fi |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| web: npx startup start -w ${WEB_CONCURRENCY:-4} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how does this work with the existing CRA index.html? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| const setProxies = require('exo/proxy'); | ||
| const snow = require('snow'); | ||
| const setWebpackManifest = require('snow/lib/utils/webpackManifest.js'); | ||
| const snowConfig = require('./snow.config.js'); | ||
| const hf = require('hf'); | ||
|
|
||
| /** | ||
| * Expose the app | ||
| */ | ||
| const app = module.exports = snow(__dirname, hf, snowConfig); | ||
|
|
||
| setWebpackManifest(app,'build'); | ||
|
|
||
| if (app.get('env') === 'development') { | ||
| app.stack.front(function () { | ||
| setProxies(app); | ||
| }); | ||
| } | ||
|
|
||
|
|
||
| app.stack.postRoute(function () { | ||
| app.get('/',(req,res)=>{ | ||
| res.render('index', { | ||
| indexPath: '../build/_index.html', | ||
| // _layoutFile: './async_layout' | ||
| }) | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| var urlLookup = { | ||
| 'cas-public-api.cas.ident.service': process.env.BASE_URL + '/cas-public-api', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these fallbacks use the old pattern and should be updated to the new pattern |
||
| 'cis-public-api.cis.ident.service': process.env.BASE_URL + '/cis-public-api', | ||
| }; | ||
|
|
||
| var serviceLocatorOptions = { | ||
| fallbackFunction: function (serviceName) { | ||
| if (urlLookup[serviceName]) { | ||
| return urlLookup[serviceName]; | ||
| } | ||
| throw new Error(`${serviceName} was not found in binding registry or urlLookup`); | ||
| } | ||
| }; | ||
|
|
||
| module.exports = { | ||
| experiments : [ | ||
| { | ||
| // Author/Owner: Tyler Graf | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe we recommend you put author/owner in the description now |
||
| name: 'coolExperiment', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should follow our naming convention |
||
| description: 'The coolest experiment', | ||
| default: true | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would probably do |
||
| } | ||
| ], | ||
| proxyUser: true, | ||
| cacheEncryption: true, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure how I feel about proxyUser on by default. And we should discuss making cacheEncryption defult to true |
||
| serviceLocatorOptions | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| const setProxies = require('exo/proxy'); | ||
| const hf = require('hf'); | ||
| const snow = require('snow'); | ||
| const path = require('path'); | ||
| const waitForWebpack = require('snow/lib/utils/waitForWebpack.js'); | ||
|
|
||
| const initiatedDirectory = process.env.INIT_CWD; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. who sets |
||
| const snowConfig = require(path.join(initiatedDirectory, 'snow.config.js')); | ||
|
|
||
| module.exports = app => { | ||
| setProxies(app); | ||
| waitForWebpack(app); | ||
|
|
||
| snowConfig.app = app; | ||
| snow(initiatedDirectory, hf, snowConfig); | ||
|
|
||
| app.get('/', (req, res, next) => { | ||
| res.render('index', { | ||
| indexPath: '../dist/_index.html', | ||
| // _layoutFile: './async_layout' | ||
| }); | ||
| }); | ||
|
|
||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <% | ||
| page.secondaryNav = [ | ||
| {"href": appPath("/"), title: 'Stuff', "text": 'Stuff'}, | ||
| ]; | ||
| page.showHelper = true; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we fell that every app should have helper and secondaryNav setup by default? what about several other page variables that they could enable? |
||
| %> | ||
| <h1>hi</h1> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi to you to. But I don't think it's useful in the default template |
||
| <div id="root"></div> | ||
| <%- include(indexPath) %> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,8 +11,12 @@ | |
| # production | ||
| /build | ||
|
|
||
| # development | ||
| /dist | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wait, we create a |
||
|
|
||
| # misc | ||
| .DS_Store | ||
| .env | ||
| .env.local | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have some sort of pattern for alternate .env files? Should we just do |
||
| .env.development.local | ||
| .env.test.local | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we should default electric-flow to on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know if this is true, but I was under the assumption that what Tyler did with the HF templating expects EF to be true/on as well.
Tyler would have to chime in further though.