Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
release: public 2.1.1
Browse files Browse the repository at this point in the history
JIRA-Ref: release/2.1.1
  • Loading branch information
aharnum-ods committed May 26, 2023
0 parents commit e73b905
Show file tree
Hide file tree
Showing 379 changed files with 16,897 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .app-eleventy.js
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,
};
83 changes: 83 additions & 0 deletions .core-eleventy.js
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,
};
10 changes: 10 additions & 0 deletions .eleventy.js
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 };
};
17 changes: 17 additions & 0 deletions .eslintrc.js
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,
};
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
tmp
tests_output
logs
10 changes: 10 additions & 0 deletions .htmlvalidate.json
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"
}
}
3 changes: 3 additions & 0 deletions .htmlvalidateignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
src/jamstack-toolkit/assets/vendor/**
dist/assets/vendor/**
tests_output
6 changes: 6 additions & 0 deletions .jam-on/app/conf.json
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"
}
21 changes: 21 additions & 0 deletions .jam-on/core/templates/README.njk
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?
9 changes: 9 additions & 0 deletions .jam-on/core/templates/en.njk
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.
10 changes: 10 additions & 0 deletions .jam-on/core/templates/fr.njk
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
31 changes: 31 additions & 0 deletions .jam-on/core/templates/package.njk
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"
}
}
16 changes: 16 additions & 0 deletions .jam-on/core/templates/redirect.njk
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 %}
47 changes: 47 additions & 0 deletions .jam-on/core/templates/test.njk
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`));
});
});
});
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v17.0.1
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
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]
9 changes: 9 additions & 0 deletions .prettierignore
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
17 changes: 17 additions & 0 deletions .prettierrc.json
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
}
}
]
}
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
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.
Loading

0 comments on commit e73b905

Please sign in to comment.