From 9a85de8798e33a65e7bc039a31a6adbbeab67b50 Mon Sep 17 00:00:00 2001 From: Tobias Bocanegra Date: Thu, 9 Aug 2018 14:09:49 +0200 Subject: [PATCH] [hlx init] should create minimal example (Fixes #66) (#68) --- .eslintignore | 1 + layouts/{default => complete}/README.md | 0 layouts/complete/_gitignore | 5 + .../{default => complete}/helix-config.yaml | 0 layouts/complete/helix_logo.png | Bin 0 -> 7517 bytes layouts/complete/index.md | 23 ++++ layouts/{default => complete}/package.json | 0 layouts/complete/src/html.htl | 37 ++++++ layouts/complete/src/html.pre.js | 30 +++++ .../src/static/bootstrap.min.css | 0 layouts/complete/src/static/favicon.ico | Bin 0 -> 2633 bytes layouts/default/src/html.htl | 9 +- layouts/default/src/html.pre.js | 20 ++-- layouts/default/src/static/style.css | 16 +++ package-lock.json | 80 +------------ package.json | 2 +- src/init.cmd.js | 110 +++++++----------- test/testInitCmd.js | 5 +- 18 files changed, 172 insertions(+), 166 deletions(-) rename layouts/{default => complete}/README.md (100%) create mode 100644 layouts/complete/_gitignore rename layouts/{default => complete}/helix-config.yaml (100%) create mode 100644 layouts/complete/helix_logo.png create mode 100644 layouts/complete/index.md rename layouts/{default => complete}/package.json (100%) create mode 100644 layouts/complete/src/html.htl create mode 100644 layouts/complete/src/html.pre.js rename layouts/{default => complete}/src/static/bootstrap.min.css (100%) create mode 100644 layouts/complete/src/static/favicon.ico create mode 100644 layouts/default/src/static/style.css diff --git a/.eslintignore b/.eslintignore index c5cfbc96b..c4fa276d3 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,6 @@ .vscode/* logs/* +layouts/complete/src/html.pre.js layouts/default/src/html.pre.js test/integration test/tmp/* diff --git a/layouts/default/README.md b/layouts/complete/README.md similarity index 100% rename from layouts/default/README.md rename to layouts/complete/README.md diff --git a/layouts/complete/_gitignore b/layouts/complete/_gitignore new file mode 100644 index 000000000..eb5c490ff --- /dev/null +++ b/layouts/complete/_gitignore @@ -0,0 +1,5 @@ +.hlx/ +.cache/ +node_modules/ +pipeline.log +logs diff --git a/layouts/default/helix-config.yaml b/layouts/complete/helix-config.yaml similarity index 100% rename from layouts/default/helix-config.yaml rename to layouts/complete/helix-config.yaml diff --git a/layouts/complete/helix_logo.png b/layouts/complete/helix_logo.png new file mode 100644 index 0000000000000000000000000000000000000000..0c41086b8d479c7377b3a1f42922a3beff62c776 GIT binary patch literal 7517 zcmV-j9irliP)c_LnHzPJ3x^G1}qvZwX{Synb-*_v?ybVKm)`gwnH)^ z6d_O25dFcH47Oz~-Rr!)-=6mF_U-Q7?cUz`exI40`=is{-rK$R-QWBDW1Mry7tX!9 zx)A_&0YDAz(g*;w9C&zgHg9&4APAxeQL_EY=U!di?8UHs=$h(sO@(1qg&I`_z-_gv z!f+8D7lI&&ydrC{002+KLen6kX;7wV`u*6Z>RZEyuhT6Kf*=SYAT$p?w)xzvtIM-p zD$+D4k1vR&u8ftNA6$5SwRqeQ0BiB7-5j9jh3`!6%Vr-4f*=TMys#_;9ofEts=_X` zBp|`M&|pr}AVCB)4Td!h)*7!-#eEfaUHsMRa``6^1VIp);+0r*H?(E9RP?iZCiiI? z3|K5fb^Pp}C99?RYt^-y1`WpF)g^(c(KK(C#0Y{Qh(x>+3&HUDS^5_CY?+K`D!)`y z`K@A8HGbZnZ%_7{U!$qKR#UmS1y$pqC2qA@e+z;j2qFb9d=>^}LNG4ssBZpwZ|1&( zr|*~&(NEF{C{2Tj1eZple}f{Y2!bGdz)Q;l48gc$Q+1192kWWZrY1BMZnf}l4E)#a zQz;^KMR!%>72Q>lE4r)5pFt1=ks(}^$INvv1w8-B$(0Eqnfn^U{|*dKx*h*KFq#X{Ua z7z#n;N4HGne0k`~JF50^fQF=}_y6$bDazR(2!coxua}{c5oJ5}{PmqxyISwA%9-0hKEmagTMGyp$CVq>Bfk>Wv{R_QSy&Jdr?>o>`5Ppq0vrj|CO;dq< z7X(2NX_70kFt`B#Cfc@F^<4X1|3u@l8>eP94SG#ArVQ)i;P*C>&w?NbB3*J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VH1#epqt*nYJ)n*r}@pPGH(s;Qo>e>*KiV{e9WcM;oS{kgLe3p4k8e!742`e||1e`%g1^$~f7DEh`ZXBHcU%@Rb8aFu8AttTp* zf$I@bqO8ZRZ+^x(8Y)x%=|3yWH4Qp66(XtzH6G+y7>u;m&$#W;K@bE%nD8Vi@AjWm zmIFZfH~!LF5$PSNY|&Kc&@{f9#DX9QA~>=Vi#wjGtkrWUxSoR{N^I;FIT<&9%3INR z==pH1szQ${y56Z!Mq)t_1d&@Dlk)5km1^~5yLc-JSc`2|JuRK#eT^*~ZhrJ%u*7}*= z!Le{Z77g6s_4^Y9K@>AthtA&jtR6NiqM`Qv{l`)*iu-<6+0Roa@2%H=eA>4j6IhbG zKdFB>`78*6ATq?4=0^tGp3{3_zixhxFNIFM_bV6sm)tiv7H-5OLPIb}EC_-iG9;^I zC?~8P-EncM#W34A5B!fVE=EP$iEBSP)1T>Qx7N>yKHRk^7!6*2FM=S5V#AkCc?PDE z=2lxmXzlhF!Vy)4*A)f2aoh3G^Wlue0%C$Oi{e9$Z-O9*Ebvt<+Ao+9g$NH?2*v*P z3uY4h8^T$h9EK~JE%m(^&T8pMSQzN^CJ2HcGQ?N0fS7gBqF1h65{ePgC&T=j?~aC> z^-g?=A-Kltz3?*#vG6rXkRS-+RK{1Ih2W|t{mQ<@?lp=6Qb#xE*-!FfIcjh$?0L8@ zK@dc-;JanvhK=XVOrXU9NzIn#R0Vc<^f4qB1VIoP;%n$^I{e$O^df;m7*^xIi4q +![helix-logo](./helix_logo.png) + +Helix - {{project.name}} +======================= + +It works! +--------- diff --git a/layouts/default/package.json b/layouts/complete/package.json similarity index 100% rename from layouts/default/package.json rename to layouts/complete/package.json diff --git a/layouts/complete/src/html.htl b/layouts/complete/src/html.htl new file mode 100644 index 000000000..a3c7075ac --- /dev/null +++ b/layouts/complete/src/html.htl @@ -0,0 +1,37 @@ + + + + + + + + ${it.resource.title} + + + + +
+
${item}
+
+ +
+ generated at ${it.resource.time} +
+ + + diff --git a/layouts/complete/src/html.pre.js b/layouts/complete/src/html.pre.js new file mode 100644 index 000000000..e8af5167e --- /dev/null +++ b/layouts/complete/src/html.pre.js @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// the most compact way to write a html.pre.js: +// +// module.exports.pre is a function (taking next as an argument) +// that returns a function (with payload, secrets, logger as arguments) +// that calls next (after modifying the payload a bit) +module.exports.pre = next => (payload, secrets, logger) => { + const mypayload = Object.assign({}, payload); + + mypayload.resource.time = `${new Date()}`; + + return next(mypayload, secrets, logger); +}; diff --git a/layouts/default/src/static/bootstrap.min.css b/layouts/complete/src/static/bootstrap.min.css similarity index 100% rename from layouts/default/src/static/bootstrap.min.css rename to layouts/complete/src/static/bootstrap.min.css diff --git a/layouts/complete/src/static/favicon.ico b/layouts/complete/src/static/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..d06254c4d6ab87cf26c5f56890839501256424ce GIT binary patch literal 2633 zcmV-P3byr$P)3#wjU|PXtk<7SUqHM+c}nNU2m* z9zu~S7{(DttAI1efTGB&D4?;5KpluQn`I&bCY$7*{;^94d2IHP+v!a6ojJLidw=)$ z``+LEo!|MLa}RW&10Co<2mXH{yij`S-TCZUQjt*RvPte8_<^z`j6ivy`0WJbQ-8#P_>Jh&NNRRa1(UySYaK!HezYlyq zjsRTyP=1av?9!U8#_-|KAIkTNUjw`{aA)6p@^4Ng;268w7<-E`_EBT(tpM8C3w=J@ z)9j>DgqPYEASB>&c9VHaXK0l;x60t_p$a5c_<(W1F(4&T;2B_6abd*Ma@dmy*t4YKTd5cUB%Tqq4hMJ)*q$gF zo?06k@Z_4%6Hl!TU6Q69?~>s5=PPzdNk3pi25Nc(TT08C=Y~1!Lj_v1$rxs6&89i) zLs{t<@N^W|G^gUw;;Qg1zdriI{m+tCkkZx#%cvl!w0_oIU#J1cEZvwx=Hc^s$GC@`4*}6p8|RZ8$;g`zJUsB%34sd>|6$>U)4W zKzVUt>N&uh2yo(WKi*{Q;p?p8Wmhm)LX}JGp_?9w|2EaobKMF4-N!f58Wyx>tGF-% zurFP%X*rw9zr%+<4s(uOIw-hvoDgI_mg&O&-28@Ex(agA1HjTo_6CJ)$X6jsT^Q zLV&fg|4$toqpVWX=bXA@NY)_0);H?LqEU-O0kUo(9MlD`edx3ODfsG6&LU6Z| z+%|oA=XVa(d_SO@uf7{J8Xe-b0}4bv*wZz{sVcH6Rj$b(RGEE4xc20^3x(X z5Ow(OxI@Ta&*lDVE>_h9gpEan;B+M^fqM2MnVqh^L`XZe-1S1<{T3zwZ!DV}p4sGb z1<*YiJwI5*RyT{?IzTT~!zK0A~>4 zGbSv|yQqoCs#JBl2)=D<&=QVJn>TPXUgtNAJ&p2;As2#}JKLf9&xGf-`< zXj%UKiiwh%@Gv(V9883<| z#qCVL1GHkR)}Ujhal$^o&ePlaF# z@MWev(nY%`!Kc@SMq0}&z)>L>Q8K);%`tqzmLOU))G<6@4A)E9;)^+0To`Hh^?-K& zFrpRHj3!rWdML&CWbV25iUN7mooH!=#i6nK^N@*a1~S#S(6r?@b3etYxte5t0%ijT rt>te?s7Yx{Z3jBgfev(_18w6!uK^r@=sk#Q00000NkvXXu0mjf0HEKJ literal 0 HcmV?d00001 diff --git a/layouts/default/src/html.htl b/layouts/default/src/html.htl index a3c7075ac..524b992c1 100644 --- a/layouts/default/src/html.htl +++ b/layouts/default/src/html.htl @@ -21,17 +21,16 @@ ${it.resource.title} - +
-
${item}
+
${item}
-
- generated at ${it.resource.time} -
+
+generated at ${it.resource.time} diff --git a/layouts/default/src/html.pre.js b/layouts/default/src/html.pre.js index e8af5167e..25ff2ffe1 100644 --- a/layouts/default/src/html.pre.js +++ b/layouts/default/src/html.pre.js @@ -16,15 +16,13 @@ * */ -// the most compact way to write a html.pre.js: -// -// module.exports.pre is a function (taking next as an argument) -// that returns a function (with payload, secrets, logger as arguments) -// that calls next (after modifying the payload a bit) -module.exports.pre = next => (payload, secrets, logger) => { - const mypayload = Object.assign({}, payload); - - mypayload.resource.time = `${new Date()}`; +/** + * The 'pre' function that is executed before the HTML is rendered + * @param payload The current payload of processing pipeline + * @param payload.resource The content resource + */ +function pre(payload) { + payload.resource.time = `${new Date()}`; +} - return next(mypayload, secrets, logger); -}; +module.exports.pre = pre; diff --git a/layouts/default/src/static/style.css b/layouts/default/src/static/style.css new file mode 100644 index 000000000..ffb46f86c --- /dev/null +++ b/layouts/default/src/static/style.css @@ -0,0 +1,16 @@ +/* + * Copyright 2018 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +body { + padding: 8px; + background-color: white; + font-family: Arial, sans-serif; +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index b846fbaa4..ea82c26c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -112,9 +112,9 @@ } }, "@adobe/parcel-plugin-htl": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/@adobe/parcel-plugin-htl/-/parcel-plugin-htl-0.4.1.tgz", - "integrity": "sha512-WIewGuRE4VmwTDeeRBRJsJpug+W1AhB4e0NifQiOn6ujxZrjZAQ5z3ZfQjkrRP0jo4xg53BmLXmWUYiIbc5Cog==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@adobe/parcel-plugin-htl/-/parcel-plugin-htl-0.5.0.tgz", + "integrity": "sha512-BY1NR1zbONCilcfHaaEygwYNFPGJed/ydFN0YCyTG1l48U79dwalnsh4tMWAItBtW+VWU36CEm0GYKLV9uUY5A==", "requires": { "@adobe/htlengine": "^1.0.2-SNAPSHOT.26", "@adobe/hypermedia-pipeline": "^0.3.2-SNAPSHOT.74", @@ -123,80 +123,6 @@ "parcel-bundler": "^1.9.6", "snyk": "^1.88.1", "winston": "^3.0.0" - }, - "dependencies": { - "cssnano": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/cssnano/-/cssnano-4.0.5.tgz", - "integrity": "sha512-P2O0sz/YAAzqZVsSWOrbliPCr0c6abwVNQmFZ48AgejN/GbzwEf6IVFGQAj0UKHC+crv60wUAPQocAnDmeWlkg==", - "requires": { - "cosmiconfig": "^5.0.0", - "cssnano-preset-default": "^4.0.0", - "is-resolvable": "^1.0.0", - "postcss": "^6.0.0" - } - }, - "parcel-bundler": { - "version": "1.9.7", - "resolved": "https://registry.npmjs.org/parcel-bundler/-/parcel-bundler-1.9.7.tgz", - "integrity": "sha512-x+RiXe/C+aOoFuw+acH/NKjKmUJ/2zbFWFUS/KE5jBk2ErsN0Dc3OxLpmEaeIMU4oMPWFeNm5mRXcXdeUwf7GA==", - "requires": { - "ansi-to-html": "^0.6.4", - "babel-code-frame": "^6.26.0", - "babel-core": "^6.25.0", - "babel-generator": "^6.25.0", - "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0", - "babel-plugin-transform-react-jsx": "^6.24.1", - "babel-preset-env": "^1.7.0", - "babel-template": "^6.26.0", - "babel-traverse": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.17.4", - "babylon-walk": "^1.0.2", - "browserslist": "^3.2.6", - "chalk": "^2.1.0", - "clone": "^2.1.1", - "command-exists": "^1.2.6", - "commander": "^2.11.0", - "cross-spawn": "^6.0.4", - "cssnano": "^4.0.0", - "deasync": "^0.1.13", - "dotenv": "^5.0.0", - "fast-glob": "^2.2.2", - "filesize": "^3.6.0", - "fswatcher-child": "^1.0.3", - "get-port": "^3.2.0", - "grapheme-breaker": "^0.3.2", - "htmlnano": "^0.1.9", - "is-glob": "^4.0.0", - "is-url": "^1.2.2", - "js-yaml": "^3.10.0", - "json5": "^1.0.1", - "micromatch": "^3.0.4", - "mkdirp": "^0.5.1", - "node-forge": "^0.7.1", - "node-libs-browser": "^2.0.0", - "opn": "^5.1.0", - "ora": "^2.1.0", - "physical-cpu-count": "^2.0.0", - "postcss": "^6.0.19", - "postcss-value-parser": "^3.3.0", - "posthtml": "^0.11.2", - "posthtml-parser": "^0.4.0", - "posthtml-render": "^1.1.3", - "resolve": "^1.4.0", - "semver": "^5.4.1", - "serialize-to-js": "^1.1.1", - "serve-static": "^1.12.4", - "source-map": "0.6.1", - "strip-ansi": "^4.0.0", - "terser": "^3.7.3", - "toml": "^2.3.3", - "tomlify-j0.4": "^3.0.0", - "v8-compile-cache": "^2.0.0", - "ws": "^5.1.1" - } - } } }, "@adobe/petridish": { diff --git a/package.json b/package.json index 9a185ef57..d4e6dd313 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "@adobe/htlengine": "^1.0.2-SNAPSHOT.68", "@adobe/hypermedia-pipeline": "^0.3.2-SNAPSHOT.74", "@adobe/openwhisk-loggly-wrapper": "^0.2.0-SNAPSHOT.35", - "@adobe/parcel-plugin-htl": "0.4.1", + "@adobe/parcel-plugin-htl": "0.5.0", "@adobe/petridish": "^1.0.5", "archiver": "^2.1.1", "bluebird": "^3.5.1", diff --git a/src/init.cmd.js b/src/init.cmd.js index 60288e4d3..2c239552d 100644 --- a/src/init.cmd.js +++ b/src/init.cmd.js @@ -17,50 +17,36 @@ const fse = require('fs-extra'); const chalk = require('chalk'); const shell = require('shelljs'); +const ANSI_REGEXP = RegExp([ + '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)', + '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))', +].join('|'), 'g'); + /* eslint-disable no-console */ const LAYOUT_DEFAULT = { dir: path.resolve(__dirname, '../layouts/default'), files: [ - { - name: 'README.md', - filter: true, - msg: 'created README.md with welcome message.', - }, { name: 'helix_logo.png', }, { name: 'index.md', filter: true, - msg: 'created index.md with sample content.', }, { name: 'src/html.htl', filter: true, - msg: 'created src/html.htl with minimal example.', }, { name: 'src/html.pre.js', filter: true, - msg: 'created src/html.pre.js with minimal example.', }, { name: 'src/static/favicon.ico', }, { - name: 'src/static/bootstrap.min.css', - msg: 'created static files.', - }, - { - name: 'package.json', - filter: true, - msg: 'created package.json with sensible defaults and required dependencies.', - }, - { - name: 'helix-config.yaml', - filter: true, - msg: 'created helix-config.yaml for your convenience.', + name: 'src/static/style.css', }, { name: '.gitignore', @@ -81,44 +67,11 @@ function execAsync(cmd) { }); } -function msg(txt) { - console.log(chalk.green('+ ') + txt); -} - - -async function initGitRepository(dir) { - const pwd = shell.pwd(); - try { - shell.cd(dir); - await execAsync('git init -q'); - await execAsync('git add -A'); - await execAsync('git commit -q -m"Initial commit."'); - msg('initialized git repository.'); - } catch (e) { - throw Error(`Unable to initialize git repository: ${e}`); - } finally { - shell.cd(pwd); - } -} - -async function initNpm(dir) { - const pwd = shell.pwd(); - try { - console.log(`${chalk.yellow('+')} running npm install...`); - shell.cd(dir); - await execAsync('npm install'); - msg('setup all npm dependencies.'); - } catch (e) { - throw Error(`Unable to initialize nmp: ${e}`); - } finally { - shell.cd(pwd); - } -} - class InitCommand { constructor() { this._name = ''; this._dir = process.cwd(); + this._padding = 50; } withName(name) { @@ -133,6 +86,26 @@ class InitCommand { return this; } + msg(txt) { + const dl = txt.length - txt.replace(ANSI_REGEXP, '').length; + console.log('%s', txt.padEnd(this._padding + dl, ' ') + chalk.green('[ok]')); + } + + async initGitRepository(dir) { + const pwd = shell.pwd(); + try { + shell.cd(dir); + await execAsync('git init -q'); + await execAsync('git add -A'); + await execAsync('git commit -q -m"Initial commit."'); + this.msg(chalk.yellow('initializing git repository')); + } catch (e) { + throw Error(`Unable to initialize git repository: ${e}`); + } finally { + shell.cd(pwd); + } + } + async run() { if (!this._name) { throw new Error('init needs name.'); @@ -141,6 +114,7 @@ class InitCommand { throw new Error('init needs directory.'); } + this._padding = this._name.length + 45; const projectDir = path.resolve(path.join(this._dir, this._name)); const relPath = path.relative(process.cwd(), projectDir); if (await fse.pathExists(projectDir)) { @@ -152,8 +126,10 @@ class InitCommand { } catch (e) { throw new Error(`Unable to create project directory: ${e}`); } - msg(`created ${relPath}`); + const msgCreating = chalk.yellow('creating'); + const msgRelPath = chalk.gray(relPath); + this.msg(`${msgCreating} ${msgRelPath}`); const project = { name: this._name, @@ -173,22 +149,20 @@ class InitCommand { const srcFile = path.resolve(LAYOUT_DEFAULT.dir, f.from || f.name); const dstFile = path.resolve(projectDir, f.name); return processFile(srcFile, dstFile, f.filter).then(() => { - if (f.msg) { - msg(f.msg); - } + this.msg(`${msgCreating} ${msgRelPath}/${chalk.cyan(f.name)}`); }); }); - return Promise.all(jobs) - .then(() => initNpm(projectDir)) - .then(() => initGitRepository(projectDir)) - .then(() => { - console.log(chalk.green(`Successfully created project in ./${relPath}`)); - }) - .catch((err) => { - console.error(err); - throw err; - }); + await Promise.all(jobs); + await this.initGitRepository(projectDir); + + console.log(chalk` +Project {cyan ${this._name}} initialized {green successfully} with a simple example. +For more examples, clone or fork one from http://github.com/adobe/project-helix/. + +Next Step: start the development server and test the generated site with: +{grey $ cd ${this._name}} +{grey $ hlx up}`); } } diff --git a/test/testInitCmd.js b/test/testInitCmd.js index 5d4cef022..825299c4c 100644 --- a/test/testInitCmd.js +++ b/test/testInitCmd.js @@ -38,13 +38,10 @@ describe('Integration test for init command', () => { .withName('project1') .run(); await assertFile(path.resolve(testDir, 'project1', '.gitignore')); - await assertFile(path.resolve(testDir, 'project1', 'README.md')); await assertFile(path.resolve(testDir, 'project1', 'src/html.htl')); await assertFile(path.resolve(testDir, 'project1', 'src/html.pre.js')); - await assertFile(path.resolve(testDir, 'project1', 'helix-config.yaml')); await assertFile(path.resolve(testDir, 'project1', 'index.md')); - await assertFile(path.resolve(testDir, 'project1', 'package.json')); - await assertFile(path.resolve(testDir, 'project1', 'src/static/bootstrap.min.css')); + await assertFile(path.resolve(testDir, 'project1', 'src/static/style.css')); await assertFile(path.resolve(testDir, 'project1', 'src/static/favicon.ico')); await assertFile(path.resolve(testDir, 'project1', 'helix_logo.png')); }).timeout(3000);