Skip to content

Commit

Permalink
feat: split demo from main sdk repository
Browse files Browse the repository at this point in the history
Addresses SRGSSR/pillarbox-web#179 by migrating the demo to a standalone repository to leverage a
different build framework, specifically Vite.

1. Importing assets:
  Previously, asset imports utilised the prefix `bundle-text:` as per parcel convention.
  With the migration to Vite, this approach has been replaced, and now text imports should use the
  suffix `?inline` or `?raw` in the import statement depending on the intention (
  see [Static Asset Handling](https://vitejs.dev/guide/assets)).

  Before:
  ```javascript
  import textContent from 'bundle-text:path/to/file.txt';
  ```

  Now:
  ```javascript
  import textContent from 'path/to/file.txt?inline';
  ```

2. Stylelint changes:
   - A PostCSS plugin for Stylelint has been introduced to enable linting of CSS declarations inside
     Lit elements that use the `css` template.
   - The `stylelint-config-standard-scss` has been incorporated to enforce a more robust set of
     styles.

3. Eslint changes:
   Eslint rules have been expanded by extending both `eslint:recommended` and the standard ruleset.
   All previously established rules remain in place.

4. Removal of the Pre-push hook:
   The pre-push hook responsible for triggering tests in the demo app has been removed due to the
   absence of tests for the demo app.
  • Loading branch information
jboix committed Feb 5, 2024
1 parent 7b12ff9 commit 887d077
Show file tree
Hide file tree
Showing 67 changed files with 15,436 additions and 83 deletions.
5 changes: 5 additions & 0 deletions .commitlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"@commitlint/config-conventional"
]
}
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[*]
charset=utf-8
end_of_line=lf
insert_final_newline=true
indent_style=space
indent_size=2

[{*.ts,*.js}]
quote_type=single

[*.md]
max_line_length=100

105 changes: 105 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"standard"
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
"complexity": [
"error",
{
"max": 5
}
],
"function-paren-newline": [
"error",
"multiline-arguments"
],
"linebreak-style": [
"error",
"unix"
],
"max-depth": [
"error",
2
],
"max-len": [
"error",
{
"code": 80,
"ignoreComments": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreTrailingComments": true,
"ignoreUrls": true
}
],
"max-lines-per-function": [
"error",
{
"max": 35,
"skipComments": true
}
],
"max-nested-callbacks": [
"error",
3
],
"max-statements": [
"error",
10
],
"newline-after-var": [
"error",
"always"
],
"no-bitwise": [
"error",
{
"int32Hint": true
}
],
"no-cond-assign": [
"error",
"always"
],
"no-console": [
"error",
{
"allow": [
"warn",
"error"
]
}
],
"no-plusplus": [
"error",
{
"allowForLoopAfterthoughts": true
}
],
"padding-line-between-statements": [
"error",
{
"blankLine": "always",
"prev": "*",
"next": "return"
}
],
"semi": [
"error",
"always"
],
"space-before-function-paren": [
"error",
"never"
]
}
}
4 changes: 4 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Description

## Changes made

37 changes: 37 additions & 0 deletions .github/workflows/github-page.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Github Page

on:
push:
branches:
- main

jobs:
github-page:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
env :
CI: true
run: |
npm pkg delete scripts.prepare
npm ci
- name: Run build
run: |
npm run build
- name: Deploy GitHub Page 🚀
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: dist
31 changes: 31 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Quality

on:
merge_group:
pull_request:
branches:
- main

jobs:
quality:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
env :
CI: true
run: |
npm pkg delete scripts.prepare
npm ci
- name: Run JS and CSS linters
run: |
npm run eslint && npm run stylelint
89 changes: 8 additions & 81 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,13 @@ pids
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

Expand All @@ -57,74 +32,26 @@ web_modules/
# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
# Generated output
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
# Intellij
.idea

# Stores VSCode versions used for testing VSCode extensions
# VisualStudioCode
.vscode-test
.vscode
.history

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# macOs
.DS_Store
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit ${1}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run eslint && npm run stylelint
2 changes: 2 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
11 changes: 11 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": ["stylelint-config-standard-scss", "stylelint-config-rational-order"],
"overrides": [
{
"files": [
"*.js"
],
"customSyntax": "postcss-lit"
}
]
}
40 changes: 40 additions & 0 deletions 404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Single Page Apps for GitHub Pages</title>
<script type="text/javascript">
// Single Page Apps for GitHub Pages
// MIT License
// https://github.com/rafgraph/spa-github-pages
// This script takes the current url and converts the path and query
// string into just a query string, and then redirects the browser
// to the new url with only a query string and hash fragment,
// e.g. https://www.foo.tld/one/two?a=b&c=d#qwe, becomes
// https://www.foo.tld/?/one/two&a=b~and~c=d#qwe
// Note: this 404.html file must be at least 512 bytes for it to work
// with Internet Explorer (it is currently > 512 bytes)

// If you're creating a Project Pages site and NOT using a custom domain,
// then set pathSegmentsToKeep to 1 (enterprise users may need to set it to > 1).
// This way the code will only replace the route part of the path, and not
// the real directory in which the app resides, for example:
// https://username.github.io/repo-name/one/two?a=b&c=d#qwe becomes
// https://username.github.io/repo-name/?/one/two&a=b~and~c=d#qwe
// Otherwise, leave pathSegmentsToKeep as 0.
var pathSegmentsToKeep = 1;

var l = window.location;
l.replace(
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
l.hash
);

</script>
</head>
<body>
</body>
</html>
2 changes: 0 additions & 2 deletions README.md

This file was deleted.

Loading

0 comments on commit 887d077

Please sign in to comment.