This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JIRA-Ref: release/2.1.1
- Loading branch information
0 parents
commit e73b905
Showing
379 changed files
with
16,897 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const cc = require('config-chain'); | ||
|
||
const conf = cc(cc.find('.jam-on/app/conf.json')); | ||
|
||
function appConfigFunc(eleventyConfig) { | ||
eleventyConfig.addPassthroughCopy({ | ||
'src/assets': conf.get('assetsDestination'), | ||
}); | ||
} | ||
|
||
const appConfigObj = { | ||
dir: { | ||
input: 'src', | ||
output: 'dist', | ||
}, | ||
}; | ||
|
||
module.exports = { | ||
configFunc: appConfigFunc, | ||
configObj: appConfigObj, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
const fs = require('fs'); | ||
const matter = require('gray-matter'); | ||
const MarkdownIt = require('markdown-it'); | ||
const cc = require('config-chain'); | ||
|
||
const globalLocaleStrings = require('./src/_data/core/core-locale-strings.json'); | ||
const appLocaleStrings = require('./src/_data/app/app-locale-strings.json'); | ||
|
||
const localeStrings = { ...globalLocaleStrings, ...appLocaleStrings }; | ||
|
||
const appConf = cc(cc.find('.jam-on/app/conf.json')); | ||
const appVersionMetadata = cc(cc.find('.jam-on/app/versionMetadata.json')); | ||
let toolkitVersion; | ||
|
||
try { | ||
toolkitVersion = appVersionMetadata.get('tagOrBranch'); | ||
} catch (e) { | ||
try { | ||
toolkitVersion = appConf.get('toolkitPackageJSONVersion'); | ||
} catch { | ||
toolkitVersion = 'version undetermined'; | ||
/* eslint-disable no-console */ | ||
console.warn( | ||
"Your version of the Ontario.ca Jamstack Toolkit can't be determined and some features may not work correctly; you can try performing an upgrade to the latest release using the `jam-on.mjs` CLI to resolve this issue, or contact the Ontario.ca Service Integration team for help.", | ||
); | ||
/* eslint-enable no-console */ | ||
} | ||
} | ||
|
||
function coreConfigFunc(eleventyConfig) { | ||
const md = new MarkdownIt({ | ||
html: true, | ||
}); | ||
|
||
eleventyConfig.addFilter('markdown', (content) => md.renderInline(content)); | ||
eleventyConfig.addShortcode('toolkitVersion', () => toolkitVersion); | ||
eleventyConfig.addShortcode( | ||
'currentYear', | ||
() => `${String(new Date().getFullYear())}`, | ||
); | ||
eleventyConfig.addShortcode( | ||
'currentShortYear', | ||
() => `${String(new Date().getFullYear()).slice(-2)}`, | ||
); | ||
/* eslint-disable func-names */ | ||
eleventyConfig.addFilter('localeString', function (key) { | ||
/* eslint-enable func-names */ | ||
// Solution for accessing page front matter from https://stackoverflow.com/a/67746326 | ||
|
||
const { page } = this.ctx; | ||
const str = fs.readFileSync(page.inputPath, 'utf8'); | ||
const { data } = matter(str); | ||
const lang = data.lang || 'en'; | ||
let localeString; | ||
|
||
if (key.includes('.')) { | ||
const keyArr = key.split('.'); | ||
localeString = localeStrings[keyArr.shift()]; | ||
if (keyArr.length > 0) { | ||
keyArr.forEach((k) => { | ||
localeString = localeString[k]; | ||
}); | ||
} | ||
} else { | ||
localeString = localeStrings[key]; | ||
} | ||
if (Array.isArray(localeString)) { | ||
localeString = localeString.map((string) => string[lang]); | ||
return localeString; | ||
} | ||
|
||
return `${localeString[lang]}`; | ||
}); | ||
} | ||
|
||
const coreConfigObj = { | ||
pathPrefix: '/', | ||
}; | ||
|
||
module.exports = { | ||
configFunc: coreConfigFunc, | ||
configObj: coreConfigObj, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const core = require('./.core-eleventy'); | ||
const app = require('./.app-eleventy'); | ||
|
||
module.exports = (eleventyConfig) => { | ||
core.configFunc(eleventyConfig); | ||
app.configFunc(eleventyConfig); | ||
|
||
// Return your Object options: | ||
return { ...core.configObj, ...app.configObj }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
commonjs: true, | ||
es2021: true, | ||
node: true, | ||
}, | ||
extends: 'airbnb-base', | ||
overrides: [], | ||
ignorePatterns: ['!.*', 'dist/**', 'node_modules/**', 'src/assets/vendor/**'], | ||
parser: '@babel/eslint-parser', | ||
parserOptions: { | ||
requireConfigFile: false, | ||
}, | ||
plugins: ['prettier'], | ||
root: true, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
dist | ||
tmp | ||
tests_output | ||
logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": ["html-validate:recommended"], | ||
"rules": { | ||
"void-style": "off", | ||
"prefer-button": "off", | ||
"svg-focusable": "off", | ||
"no-trailing-whitespace": "off", | ||
"long-title": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
src/jamstack-toolkit/assets/vendor/** | ||
dist/assets/vendor/** | ||
tests_output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"assetsDestination": "example-pages/assets", | ||
"englishRoot": "example-pages", | ||
"frenchRoot": "pages-dexemple", | ||
"toolkitPackageJSONVersion": "not an initialized project" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# {{ projectName }} | ||
|
||
Built with the [Ontario.ca Jamstack Toolkit](https://github.com/ongov/Ontario.ca-Jamstack-Toolkit) - see `README.jamstack` for more details. | ||
|
||
## Project Description | ||
|
||
{{ projectDescription }} | ||
|
||
## About this README.md file | ||
|
||
README files are a place to tell others about a project right in the source code repository. This one has been generated automatically for you when you set up your new project. | ||
|
||
[Make a README](https://www.makeareadme.com/) is one place to learn about creating a good README file. | ||
|
||
## Suggested Information | ||
|
||
For projects meant to be deployed to Ontario.ca (this is probably why you're using the *Ontario.ca Jamstack Toolkit, after all), we recommend putting in at least the following information to start: | ||
|
||
* What is the purpose of the project? | ||
* Who should someone contact to get further information about it? | ||
* How would a new developer get started working on the project? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
layout: core/layout.njk | ||
title: "Ontario.ca Jamstack Toolkit" | ||
description: "The best way to start building applications for Ontario.ca." | ||
fr_page_url: "/{{ frenchRoot }}" | ||
date: {{ createDate }} | ||
published_date: {{ createDate }} | ||
--- | ||
English Page. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
layout: core/layout.njk | ||
title: "Boîte à outils Jamstack Ontario.ca" | ||
description: "La meilleure façon de commencer à créer des applications pour Ontario.ca." | ||
lang: fr | ||
en_page_url: "/{{ englishRoot }}" | ||
date: {{ createDate }} | ||
published_date: {{ createDate }} | ||
--- | ||
French Page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "{{ projectName }}", | ||
"version": "0.0.1", | ||
"description": "{{ projectDescription }}", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "npm run build && mocha", | ||
"lint": "rm -rf dist && eleventy & npm run htmlValidateDist", | ||
"build": "rm -rf dist && eleventy", | ||
"serve": "eleventy --serve", | ||
"htmlValidateSrc": "html-validate src/**/*.njk", | ||
"htmlValidateDist": "html-validate dist/**/*.html", | ||
"formatCode": "npx prettier --write .", | ||
"installDesignSystem": "export DS_VERSION=0.12.13 && export DS_ZIP_NAME=ontario-design-system.zip && export VEN_DIR=src/assets/vendor && export DS_UNZIP_DIR=$VEN_DIR/ontario-design-system && curl https://designsystem.ontario.ca/dist/ontario-design-system-dist-$DS_VERSION.zip > $VEN_DIR/$DS_ZIP_NAME && unzip -o $VEN_DIR/$DS_ZIP_NAME -d $DS_UNZIP_DIR && rm $VEN_DIR/$DS_ZIP_NAME && rm $DS_UNZIP_DIR/version-release-notes-*.* && rm -rf $DS_UNZIP_DIR/html-samples && rm $DS_UNZIP_DIR/index.html && rm $DS_UNZIP_DIR/package.json && rm -rf $DS_UNZIP_DIR/styles/components && rm -rf $DS_UNZIP_DIR/styles/sass && rm -rf $DS_UNZIP_DIR/fonts/ds-fonts.zip" | ||
}, | ||
"author": "", | ||
"license": "", | ||
"devDependencies": { | ||
"@11ty/eleventy": "^1.0.1", | ||
"commander": "^9.3.0", | ||
"dotenv": "^16.0.0", | ||
"fs-extra": "^10.1.0", | ||
"html-validate": "^6.1.0", | ||
"inquirer": "^9.0.0", | ||
"mocha": "^9.1.3", | ||
"prettier": "2.6.2", | ||
"simple-git": "^3.10.0", | ||
"uuid": "^8.3.2", | ||
"validate-npm-package-name": "^4.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
redirect: "/{{ englishRoot }}" | ||
--- | ||
{% raw %} | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="refresh" content="0; url='{{ redirect }}'" /> | ||
<title>Redirecting...</title> | ||
</head> | ||
<body> | ||
Redirecting to: <a href="{{ redirect }}">{{ redirect }}</a> | ||
</body> | ||
</html> | ||
{% endraw %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
|
||
const enRoot = '{{ englishRoot }}'; | ||
const frRoot = '{{ frenchRoot }}'; | ||
const assetsDestination = '{{ assetsDestination }}'; | ||
const odsDir = `dist/${assetsDestination}/vendor/ontario-design-system`; | ||
const enPageLocation = `dist/${enRoot}/index.html`; | ||
const frPageLocation = `dist/${frRoot}/index.html`; | ||
const expectedNoDsFiles = 5; | ||
|
||
describe('Site generation', function () { | ||
describe('Top-level redirect page present', function () { | ||
it('should generate a top-level redirect page', function () { | ||
assert(fs.existsSync('dist/index.html')); | ||
}); | ||
}); | ||
describe('English-language example page present', function () { | ||
it('should generate an English-language example page', function () { | ||
assert(fs.existsSync(enPageLocation)); | ||
}); | ||
}); | ||
describe('French-language example page present', function () { | ||
it('should generate a French-language example page', function () { | ||
assert(fs.existsSync(frPageLocation)); | ||
}); | ||
}); | ||
describe('Ontario design system inclusion', function () { | ||
it('should copy over the design system assets', function () { | ||
assert( | ||
fs.existsSync(odsDir), | ||
'Expected directory for design system not found' | ||
); | ||
const actualLength = fs.readdirSync(odsDir).length; | ||
const expectedLength = expectedNoDsFiles; | ||
assert( | ||
actualLength === expectedLength, | ||
`The expected number of files in design system directory were not found, expected ${expectedLength}, got ${actualLength}` | ||
); | ||
}); | ||
}); | ||
describe('Site CSS file present', function () { | ||
it('Should copy over the site CSS file', function () { | ||
assert(fs.existsSync(`dist/${assetsDestination}/css/style.css`)); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v17.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://git.ontariogovernment.ca/service-integration/team-tools/pre-commit | ||
rev: 936a9f4fb1e06f62fc4ea86c59439c4774e57131 | ||
hooks: | ||
- id: npm-run-test | ||
always_run: true | ||
stages: [commit] | ||
- id: npm-run-validate-html | ||
always_run: true | ||
stages: [commit] | ||
- id: npm-run-format-code | ||
always_run: true | ||
stages: [commit] | ||
- id: npm-run-lint | ||
always_run: true | ||
stages: [commit] | ||
- id: check-whitespace | ||
always_run: true | ||
stages: [commit] | ||
- id: add-jira-ref | ||
always_run: true | ||
stages: [prepare-commit-msg] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# ignore artifacts | ||
node_modules | ||
dist | ||
|
||
# ignore design system | ||
src/assets/vendor/* | ||
|
||
# ignore njk files | ||
*.njk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"printWidth": 80, | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"bracketSpacing": true, | ||
"bracketSameLine": true, | ||
"overrides": [ | ||
{ | ||
"files": "*.md", | ||
"options": { | ||
"singleQuote": false | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Contributing to the Ontario.ca Jamstack Toolkit | ||
|
||
[Available in French](CONTRIBUTING.fr.md) | ||
|
||
For information on how to contribute to the Ontario.ca Jamstack Toolkit, check out the contribution guidelines section of the documentation posted in the Ontario.ca Jamstack Toolkit team in Microsoft Teams. |
Oops, something went wrong.