Skip to content

Commit

Permalink
Merge branch 'playground' into browser-code-editor
Browse files Browse the repository at this point in the history
* playground:
  Upgrade deps
  Trying different approach for cleaning cache file of releases
  Convert "releases" data file to TS
  Don't check SVGs
  update image paths for jquery vendor images
  Fix typos in Code styleguide
  Only check external links once a month
  Check links in CI
  Check and fix internal links
  Let dependabot handle upgrades
  Cut a release for a new Dart Sass version
  Document the default export deprecation (sass#736)
  • Loading branch information
jgerigmeyer committed Jun 19, 2023
2 parents dee9a29 + 5bb7f5d commit 0099510
Show file tree
Hide file tree
Showing 29 changed files with 539 additions and 381 deletions.
8 changes: 0 additions & 8 deletions .github/dependabot.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/check-links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Check Links

on:
workflow_dispatch: # Allow running on-demand
schedule:
# 1st of every month at 8:00 UTC (4:00 Eastern)
- cron: '0 8 1 * *'

jobs:
check:
name: Check Links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: yarn
- name: Install dependencies
run: yarn install --immutable
- name: Build site
run: yarn build-prod
- name: Check for broken internal links
run: yarn checklinks:internal
- name: Check for broken external links
run: yarn checklinks:external
28 changes: 15 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ concurrency:
cancel-in-progress: true

jobs:
# test:
# name: Test
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version-file: .nvmrc
# cache: yarn
# - name: Install dependencies
# run: yarn install --immutable
# - name: Test
# run: yarn test
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: yarn
- name: Install & build
run: |
yarn install --immutable
yarn build-prod
- name: Check links
run: yarn checklinks:internal

lint:
name: Lint
Expand Down
59 changes: 0 additions & 59 deletions .github/workflows/upgrade-deps.yml

This file was deleted.

1 change: 1 addition & 0 deletions eleventy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = (eleventyConfig) => {
eleventyConfig.addDataExtension('yml, yaml', (contents) =>
yaml.load(contents),
);
eleventyConfig.addDataExtension('ts', (_, filepath) => require(filepath));

// register filters and shortcodes
eleventyConfig.addPlugin(componentsPlugin);
Expand Down
24 changes: 14 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
"packageManager": "[email protected]",
"scripts": {
"serve": "run-p 'watch:**'",
"build": "REBUILD_VERSION_CACHE=true run-s build-dev:scripts 'build:**'",
"build-prod": "NETLIFY=true run-s build-prod:scripts 'build:**'",
"build": "run-s clean-version-cache build-dev:scripts 'build:**'",
"clean-version-cache": "rm -f source/_data/versionCache.json",
"build-prod": "NETLIFY=true run-s clean-version-cache build-prod:scripts 'build:**'",
"build:sass": "sass --style=compressed ./source/assets/sass/sass.scss:./source/assets/dist/css/sass.css ./source/assets/sass/noscript.scss:./source/assets/dist/css/noscript.css",
"watch:sass": "sass --watch ./source/assets/sass/sass.scss:./source/assets/dist/css/sass.css ./source/assets/sass/noscript.scss:./source/assets/dist/css/noscript.css",
"build-dev:scripts": "rollup -c",
Expand All @@ -36,7 +37,9 @@
"stylelint:ci": "stylelint '**/*.{css,scss}'",
"lint": "run-s prettier gts stylelint tsc",
"lint:ci": "run-s prettier:ci gts:ci stylelint:ci tsc",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"checklinks:internal": "npx --yes --package=hyperlink --package=tap-spot -- 'hyperlink --canonicalroot https://sass-lang.com/ --root _site/ -r -p -i --skip \".css.map\" --skip \".js.map\" --skip \".svg\" --skip \"feed.atom\" --skip \"/documentation/js-api/\" --skip \"/blog/\" _site/index.html | tap-spot'",
"checklinks:external": "npx --yes --package=broken-link-checker -- 'blc -ro --exclude=localhost:8080 --exclude=codepen.io --exclude=linkedin.com --exclude=docs.github.com --exclude=twitter.com https://sass-lang.com'"
},
"devDependencies": {
"@11ty/eleventy": "^2.0.1",
Expand All @@ -47,11 +50,12 @@
"@babel/preset-typescript": "^7.22.5",
"@codemirror/lang-sass": "^6.0.1",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-commonjs": "^25.0.1",
"@rollup/plugin-commonjs": "^25.0.2",
"@rollup/plugin-inject": "^5.0.3",
"@rollup/plugin-node-resolve": "^15.1.0",
"@rollup/plugin-terser": "^0.4.3",
"@sindresorhus/slugify": "^1.1.2",
"@types/deep-equal": "^1.0.1",
"@types/jquery": "^3.5.16",
"@types/jqueryui": "^1.12.17",
"@types/lodash": "^4.14.195",
Expand All @@ -60,13 +64,13 @@
"@types/markdown-it-footnote": "^3.0.0",
"@types/node": "^16",
"@types/prismjs": "^1.26.0",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.60.0",
"cheerio": "^1.0.0-rc.12",
"codemirror": "^6.0.1",
"date-fns": "^2.30.0",
"deep-equal": "^2.2.1",
"eslint": "^8.42.0",
"eslint": "^8.43.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
Expand All @@ -89,10 +93,10 @@
"prettier": "^2.8.8",
"prismjs": "^1.29.0",
"rollup": "^3.25.1",
"sass": "^1.63.3",
"semver-parser": "^4.1.4",
"sass": "^1.63.4",
"semver": "^7.5.2",
"strip-indent": "^3.0.0",
"stylelint": "^15.7.0",
"stylelint": "^15.8.0",
"stylelint-config-standard-scss": "^9.0.0",
"truncate-html": "^1.0.4",
"ts-node": "^10.9.1",
Expand Down
2 changes: 1 addition & 1 deletion source/_data/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ toc:
- Breaking Changes: /documentation/breaking-changes/
:children:
- Strict Unary Operators: /documentation/breaking-changes/strict-unary/
- Random With Units: /documentation/breaking-changes/random-with-units/
- Random With Units: /documentation/breaking-changes/function-units/
- Invalid Combinators: /documentation/breaking-changes/bogus-combinators/
- Media Queries Level 4: /documentation/breaking-changes/media-logic/
- <code>/</code> as Division: /documentation/breaking-changes/slash-div/
Expand Down
64 changes: 35 additions & 29 deletions source/_data/releases.js → source/_data/releases.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
const { spawn: nodeSpawn } = require('node:child_process');
const fs = require('node:fs/promises');
import {
spawn as nodeSpawn,
SpawnOptionsWithoutStdio,
} from 'node:child_process';
import fs from 'node:fs/promises';

const deepEqual = require('deep-equal');
const kleur = require('kleur');
import deepEqual from 'deep-equal';
import kleur from 'kleur';
import { compare, parse } from 'semver';

type VersionCache = Record<string, string>;

const VERSION_CACHE_PATH = './source/_data/versionCache.json';

/**
* Promise version of `spawn` to avoid blocking the main thread while waiting
* for the child processes.
*/
const spawn = (cmd, args, options) => {
const spawn = (
cmd: string,
args: string[],
options: SpawnOptionsWithoutStdio,
) => {
return new Promise((resolve, reject) => {
const child = nodeSpawn(cmd, args, options);
const stderr = [];
const stdout = [];
child.stdout.on('data', (data) => {
const stderr: string[] = [];
const stdout: string[] = [];
child.stdout.on('data', (data: Buffer) => {
stdout.push(data.toString());
});
child.on('error', (e) => {
child.on('error', (e: Error) => {
stderr.push(e.toString());
});
child.on('close', () => {
Expand All @@ -35,14 +45,12 @@ const spawn = (cmd, args, options) => {
* Retrieves cached version object from cache file.
*/
const getCacheFile = async () => {
if (process.env.NETLIFY || process.env.REBUILD_VERSION_CACHE) {
return {};
}
let versionCache;
try {
versionCache = JSON.parse(await fs.readFile(VERSION_CACHE_PATH));
const versionFile = await fs.readFile(VERSION_CACHE_PATH);
versionCache = JSON.parse(versionFile.toString()) as VersionCache;
} catch (err) {
if (err.code === 'ENOENT') {
if ((err as NodeJS.ErrnoException).code === 'ENOENT') {
versionCache = {}; // Cache is missing and needs to be created
} else {
throw err;
Expand All @@ -54,7 +62,7 @@ const getCacheFile = async () => {
/**
* Writes version object to cache file.
*/
const writeCacheFile = async (cache) => {
const writeCacheFile = async (cache: VersionCache) => {
// eslint-disable-next-line no-console
console.info(kleur.green(`[11ty] Writing version cache file...`));
await fs.writeFile(VERSION_CACHE_PATH, JSON.stringify(cache));
Expand All @@ -63,39 +71,37 @@ const writeCacheFile = async (cache) => {
/**
* Retrieves the highest stable version of `repo`, based on its git tags.
*/
const getLatestVersion = async (repo) => {
const getLatestVersion = async (repo: string) => {
// eslint-disable-next-line no-console
console.info(kleur.cyan(`[11ty] Fetching version information for ${repo}`));
const { parseSemVer, compareSemVer } = await import('semver-parser');
let stdout;
try {
stdout = await spawn(
stdout = (await spawn(
'git',
['ls-remote', '--tags', '--refs', `https://github.com/${repo}`],
{ env: { ...process.env, GIT_TERMINAL_PROMPT: 0 } },
);
{ env: { ...process.env, GIT_TERMINAL_PROMPT: '0' } },
)) as string;
} catch (err) {
// eslint-disable-next-line no-console
console.error(kleur.red(`[11ty] Failed to fetch git tags for ${repo}`));
throw err;
}
const isNotPreRelease = (version) => {
const parsed = parseSemVer(version);
return parsed.matches && !parsed.pre;
const isNotPreRelease = (version: string) => {
const parsed = parse(version);
return parsed && parsed.prerelease.length === 0;
};
const version = stdout
.split('\n')
.map((line) => line.split('refs/tags/').at(-1))
.map((line) => line.split('refs/tags/').at(-1) ?? '')
.filter(isNotPreRelease)
.sort(compareSemVer)
.sort(compare)
.at(-1);

return version;
return version ?? '';
};

/**
* Returns the version and URL for the latest release of the given
* implementation.
* Returns the version and URL for the latest release of all implementations.
*/
module.exports = async () => {
const repos = ['sass/libsass', 'sass/dart-sass', 'sass/migrator'];
Expand All @@ -114,7 +120,7 @@ module.exports = async () => {
]),
);

const nextCache = Object.fromEntries(versions);
const nextCache = Object.fromEntries(versions) as VersionCache;
if (!deepEqual(cache, nextCache)) {
await writeCacheFile(nextCache);
}
Expand Down
2 changes: 1 addition & 1 deletion source/_includes/doc_snippets/silence-deprecations.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
[`--quiet-deps` flag], and if you're using the JavaScript API you can set the
[`quietDeps` option] to `true`.

[`--quiet-deps` flag]: /documentation/cli/dart-sass#quiet-deps
[`--quiet-deps` flag]: /documentation/cli/dart-sass/#quiet-deps
[`quietDeps` option]: /documentation/js-api/interfaces/StringOptionsWithoutImporter#quietDeps
{% endfunFact %}
Loading

0 comments on commit 0099510

Please sign in to comment.