Skip to content

Commit 0099510

Browse files
committed
Merge branch 'playground' into browser-code-editor
* 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)
2 parents dee9a29 + 5bb7f5d commit 0099510

29 files changed

+539
-381
lines changed

.github/dependabot.yml

-8
This file was deleted.

.github/workflows/check-links.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Check Links
2+
3+
on:
4+
workflow_dispatch: # Allow running on-demand
5+
schedule:
6+
# 1st of every month at 8:00 UTC (4:00 Eastern)
7+
- cron: '0 8 1 * *'
8+
9+
jobs:
10+
check:
11+
name: Check Links
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-node@v3
16+
with:
17+
node-version-file: .nvmrc
18+
cache: yarn
19+
- name: Install dependencies
20+
run: yarn install --immutable
21+
- name: Build site
22+
run: yarn build-prod
23+
- name: Check for broken internal links
24+
run: yarn checklinks:internal
25+
- name: Check for broken external links
26+
run: yarn checklinks:external

.github/workflows/test.yml

+15-13
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,21 @@ concurrency:
1010
cancel-in-progress: true
1111

1212
jobs:
13-
# test:
14-
# name: Test
15-
# runs-on: ubuntu-latest
16-
# steps:
17-
# - uses: actions/checkout@v3
18-
# - uses: actions/setup-node@v3
19-
# with:
20-
# node-version-file: .nvmrc
21-
# cache: yarn
22-
# - name: Install dependencies
23-
# run: yarn install --immutable
24-
# - name: Test
25-
# run: yarn test
13+
test:
14+
name: Test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-node@v3
19+
with:
20+
node-version-file: .nvmrc
21+
cache: yarn
22+
- name: Install & build
23+
run: |
24+
yarn install --immutable
25+
yarn build-prod
26+
- name: Check links
27+
run: yarn checklinks:internal
2628

2729
lint:
2830
name: Lint

.github/workflows/upgrade-deps.yml

-59
This file was deleted.

eleventy.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ module.exports = (eleventyConfig) => {
3737
eleventyConfig.addDataExtension('yml, yaml', (contents) =>
3838
yaml.load(contents),
3939
);
40+
eleventyConfig.addDataExtension('ts', (_, filepath) => require(filepath));
4041

4142
// register filters and shortcodes
4243
eleventyConfig.addPlugin(componentsPlugin);

package.json

+14-10
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
"packageManager": "[email protected]",
1818
"scripts": {
1919
"serve": "run-p 'watch:**'",
20-
"build": "REBUILD_VERSION_CACHE=true run-s build-dev:scripts 'build:**'",
21-
"build-prod": "NETLIFY=true run-s build-prod:scripts 'build:**'",
20+
"build": "run-s clean-version-cache build-dev:scripts 'build:**'",
21+
"clean-version-cache": "rm -f source/_data/versionCache.json",
22+
"build-prod": "NETLIFY=true run-s clean-version-cache build-prod:scripts 'build:**'",
2223
"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",
2324
"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",
2425
"build-dev:scripts": "rollup -c",
@@ -36,7 +37,9 @@
3637
"stylelint:ci": "stylelint '**/*.{css,scss}'",
3738
"lint": "run-s prettier gts stylelint tsc",
3839
"lint:ci": "run-s prettier:ci gts:ci stylelint:ci tsc",
39-
"test": "echo \"Error: no test specified\" && exit 1"
40+
"test": "echo \"Error: no test specified\" && exit 1",
41+
"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'",
42+
"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'"
4043
},
4144
"devDependencies": {
4245
"@11ty/eleventy": "^2.0.1",
@@ -47,11 +50,12 @@
4750
"@babel/preset-typescript": "^7.22.5",
4851
"@codemirror/lang-sass": "^6.0.1",
4952
"@rollup/plugin-babel": "^6.0.3",
50-
"@rollup/plugin-commonjs": "^25.0.1",
53+
"@rollup/plugin-commonjs": "^25.0.2",
5154
"@rollup/plugin-inject": "^5.0.3",
5255
"@rollup/plugin-node-resolve": "^15.1.0",
5356
"@rollup/plugin-terser": "^0.4.3",
5457
"@sindresorhus/slugify": "^1.1.2",
58+
"@types/deep-equal": "^1.0.1",
5559
"@types/jquery": "^3.5.16",
5660
"@types/jqueryui": "^1.12.17",
5761
"@types/lodash": "^4.14.195",
@@ -60,13 +64,13 @@
6064
"@types/markdown-it-footnote": "^3.0.0",
6165
"@types/node": "^16",
6266
"@types/prismjs": "^1.26.0",
63-
"@typescript-eslint/eslint-plugin": "^5.59.9",
64-
"@typescript-eslint/parser": "^5.59.9",
67+
"@typescript-eslint/eslint-plugin": "^5.60.0",
68+
"@typescript-eslint/parser": "^5.60.0",
6569
"cheerio": "^1.0.0-rc.12",
6670
"codemirror": "^6.0.1",
6771
"date-fns": "^2.30.0",
6872
"deep-equal": "^2.2.1",
69-
"eslint": "^8.42.0",
73+
"eslint": "^8.43.0",
7074
"eslint-config-prettier": "^8.8.0",
7175
"eslint-import-resolver-typescript": "^3.5.5",
7276
"eslint-plugin-import": "^2.27.5",
@@ -89,10 +93,10 @@
8993
"prettier": "^2.8.8",
9094
"prismjs": "^1.29.0",
9195
"rollup": "^3.25.1",
92-
"sass": "^1.63.3",
93-
"semver-parser": "^4.1.4",
96+
"sass": "^1.63.4",
97+
"semver": "^7.5.2",
9498
"strip-indent": "^3.0.0",
95-
"stylelint": "^15.7.0",
99+
"stylelint": "^15.8.0",
96100
"stylelint-config-standard-scss": "^9.0.0",
97101
"truncate-html": "^1.0.4",
98102
"ts-node": "^10.9.1",

source/_data/documentation.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ toc:
6161
- Breaking Changes: /documentation/breaking-changes/
6262
:children:
6363
- Strict Unary Operators: /documentation/breaking-changes/strict-unary/
64-
- Random With Units: /documentation/breaking-changes/random-with-units/
64+
- Random With Units: /documentation/breaking-changes/function-units/
6565
- Invalid Combinators: /documentation/breaking-changes/bogus-combinators/
6666
- Media Queries Level 4: /documentation/breaking-changes/media-logic/
6767
- <code>/</code> as Division: /documentation/breaking-changes/slash-div/

source/_data/releases.js source/_data/releases.ts

+35-29
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
1-
const { spawn: nodeSpawn } = require('node:child_process');
2-
const fs = require('node:fs/promises');
1+
import {
2+
spawn as nodeSpawn,
3+
SpawnOptionsWithoutStdio,
4+
} from 'node:child_process';
5+
import fs from 'node:fs/promises';
36

4-
const deepEqual = require('deep-equal');
5-
const kleur = require('kleur');
7+
import deepEqual from 'deep-equal';
8+
import kleur from 'kleur';
9+
import { compare, parse } from 'semver';
10+
11+
type VersionCache = Record<string, string>;
612

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

915
/**
1016
* Promise version of `spawn` to avoid blocking the main thread while waiting
1117
* for the child processes.
1218
*/
13-
const spawn = (cmd, args, options) => {
19+
const spawn = (
20+
cmd: string,
21+
args: string[],
22+
options: SpawnOptionsWithoutStdio,
23+
) => {
1424
return new Promise((resolve, reject) => {
1525
const child = nodeSpawn(cmd, args, options);
16-
const stderr = [];
17-
const stdout = [];
18-
child.stdout.on('data', (data) => {
26+
const stderr: string[] = [];
27+
const stdout: string[] = [];
28+
child.stdout.on('data', (data: Buffer) => {
1929
stdout.push(data.toString());
2030
});
21-
child.on('error', (e) => {
31+
child.on('error', (e: Error) => {
2232
stderr.push(e.toString());
2333
});
2434
child.on('close', () => {
@@ -35,14 +45,12 @@ const spawn = (cmd, args, options) => {
3545
* Retrieves cached version object from cache file.
3646
*/
3747
const getCacheFile = async () => {
38-
if (process.env.NETLIFY || process.env.REBUILD_VERSION_CACHE) {
39-
return {};
40-
}
4148
let versionCache;
4249
try {
43-
versionCache = JSON.parse(await fs.readFile(VERSION_CACHE_PATH));
50+
const versionFile = await fs.readFile(VERSION_CACHE_PATH);
51+
versionCache = JSON.parse(versionFile.toString()) as VersionCache;
4452
} catch (err) {
45-
if (err.code === 'ENOENT') {
53+
if ((err as NodeJS.ErrnoException).code === 'ENOENT') {
4654
versionCache = {}; // Cache is missing and needs to be created
4755
} else {
4856
throw err;
@@ -54,7 +62,7 @@ const getCacheFile = async () => {
5462
/**
5563
* Writes version object to cache file.
5664
*/
57-
const writeCacheFile = async (cache) => {
65+
const writeCacheFile = async (cache: VersionCache) => {
5866
// eslint-disable-next-line no-console
5967
console.info(kleur.green(`[11ty] Writing version cache file...`));
6068
await fs.writeFile(VERSION_CACHE_PATH, JSON.stringify(cache));
@@ -63,39 +71,37 @@ const writeCacheFile = async (cache) => {
6371
/**
6472
* Retrieves the highest stable version of `repo`, based on its git tags.
6573
*/
66-
const getLatestVersion = async (repo) => {
74+
const getLatestVersion = async (repo: string) => {
6775
// eslint-disable-next-line no-console
6876
console.info(kleur.cyan(`[11ty] Fetching version information for ${repo}`));
69-
const { parseSemVer, compareSemVer } = await import('semver-parser');
7077
let stdout;
7178
try {
72-
stdout = await spawn(
79+
stdout = (await spawn(
7380
'git',
7481
['ls-remote', '--tags', '--refs', `https://github.com/${repo}`],
75-
{ env: { ...process.env, GIT_TERMINAL_PROMPT: 0 } },
76-
);
82+
{ env: { ...process.env, GIT_TERMINAL_PROMPT: '0' } },
83+
)) as string;
7784
} catch (err) {
7885
// eslint-disable-next-line no-console
7986
console.error(kleur.red(`[11ty] Failed to fetch git tags for ${repo}`));
8087
throw err;
8188
}
82-
const isNotPreRelease = (version) => {
83-
const parsed = parseSemVer(version);
84-
return parsed.matches && !parsed.pre;
89+
const isNotPreRelease = (version: string) => {
90+
const parsed = parse(version);
91+
return parsed && parsed.prerelease.length === 0;
8592
};
8693
const version = stdout
8794
.split('\n')
88-
.map((line) => line.split('refs/tags/').at(-1))
95+
.map((line) => line.split('refs/tags/').at(-1) ?? '')
8996
.filter(isNotPreRelease)
90-
.sort(compareSemVer)
97+
.sort(compare)
9198
.at(-1);
9299

93-
return version;
100+
return version ?? '';
94101
};
95102

96103
/**
97-
* Returns the version and URL for the latest release of the given
98-
* implementation.
104+
* Returns the version and URL for the latest release of all implementations.
99105
*/
100106
module.exports = async () => {
101107
const repos = ['sass/libsass', 'sass/dart-sass', 'sass/migrator'];
@@ -114,7 +120,7 @@ module.exports = async () => {
114120
]),
115121
);
116122

117-
const nextCache = Object.fromEntries(versions);
123+
const nextCache = Object.fromEntries(versions) as VersionCache;
118124
if (!deepEqual(cache, nextCache)) {
119125
await writeCacheFile(nextCache);
120126
}

source/_includes/doc_snippets/silence-deprecations.liquid

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
[`--quiet-deps` flag], and if you're using the JavaScript API you can set the
55
[`quietDeps` option] to `true`.
66

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

0 commit comments

Comments
 (0)