diff --git a/.github/workflows/curate.yml b/.github/workflows/curate.yml index 1b1b7a3a6cfc..5ab918f96124 100644 --- a/.github/workflows/curate.yml +++ b/.github/workflows/curate.yml @@ -64,6 +64,11 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Prepare a pre-release PR for the @webref/css6 package if needed + run: node tools/prepare-release.js css6 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Prepare a pre-release PR for the @webref/elements package if needed run: node tools/prepare-release.js elements env: diff --git a/.gitignore b/.gitignore index d919de9a177f..a9d232796974 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ config.json node_modules/ packages/css/*.json !packages/css/package.json +packages/css6/*.json +!packages/css6/package.json packages/elements/*.json !packages/elements/package.json packages/events/*.json diff --git a/README.md b/README.md index 13bb821d9301..ff5beb7ff817 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ The `curated` branch contains **curated extracts**. Curated extracts are generat Additionally, subsets of the curated content get manually reviewed and published as **NPM [packages](https://github.com/w3c/webref/tree/main/packages)** on a weekly basis: - [`@webref/idl`](https://www.npmjs.com/package/@webref/idl) contains a [curated](packages/idl#guarantees) version of the [`ed/idl`](ed/idl) folder. -- [`@webref/css`](https://www.npmjs.com/package/@webref/css) contains a [curated](packages/css#guarantees) version of the [`ed/css`](ed/css) folder. +- [`@webref/css`](https://www.npmjs.com/package/@webref/css) contains a [consolidated and curated](packages/css#guarantees) version of the [`ed/css`](ed/css) folder. - [`@webref/elements`](https://www.npmjs.com/package/@webref/elements) contains a [curated](packages/elements#guarantees) version of the [`ed/elements`](ed/elements) folder. -- [`@webref/events`](https://www.npmjs.com/package/@webref/events) contains a [curated](packages/events#guarantees) version of the [`ed/events`](ed/events) folder. +- [`@webref/events`](https://www.npmjs.com/package/@webref/events) contains a [consolidated and curated](packages/events#guarantees) version of the [`ed/events`](ed/events) folder. **Important:** The curated extracts only contain data for specifications that are in [good standing](https://github.com/w3c/browser-specs/#standing) (to keep the number of manually-maintained patches minimal and manageable). The NPM packages only contain curated extracts of specifications that are in good standing and that [target web browsers](https://github.com/w3c/browser-specs/#categories). @@ -69,6 +69,16 @@ Data curation brings the following guarantees. ### CSS extracts +**Important:** Starting with `@webref/css` version 7, the package contains the consolidated `ed/css.json` file, and no longer contains CSS extracts per spec. See the [changelog](packages/css/CHANGELOG.md) for "How to upgrade" considerations. + +The consolidated `ed/css.json` file, released in the `@webref/css` package, comes with the following guarantees: + +- All syntax values (the `value` keys) can be parsed by the version of [CSSTree](https://github.com/csstree/csstree) set in `peerDependencies` in `package.json`. +- Feature names (the `name` keys) are unique per type provided that the `for` key is also taken into account for functions and types. +- All features have an `href` key that targets the CSS spec that defines the feature. When the feature is extended across CSS specs, this URL targets the base definition. + +The consolidated file is generated from curated extracts in the `ed/css` folder. These extracts, released in the `@webref/css` package until version 7, come with the following guarantees: + - All values in CSS files can be parsed by the version of [CSSTree](https://github.com/csstree/csstree) used in `peerDependencies` in `package.json`. - No duplicate definitions of entries in CSS files provided that CSS extracts of [delta specs](https://github.com/w3c/browser-specs/#seriescomposition) are not taken into account (such extracts end with `-n.json`, where `n` is a level number). The term "entries" includes CSS properties, at-rules, selectors, types and functions. Please note that specs may still extend entries defined elsewhere (to define new values for CSS properties, or new selectors for at-rules). - CSS extracts contain a base definition of all CSS properties that get extended by other CSS property definitions (those for which `newValues` is set). @@ -81,6 +91,8 @@ Data curation brings the following guarantees. ### Events extracts +The consolidated `ed/events.json` file, released in the `@webref/events` package, comes with the following guarantees: + - All events have a `type` attribute that match the name of the event - All events have a `interface` attribute to describe the interface used by the Event. The Web IDL interface exists in the latest version of the [`@webref/idl` package](https://www.npmjs.com/package/@webref/idl) at the time the `@webref/events` package is released, and represents an actual interface (i.e. not a mixin). - All events have a `targets` attribute with a non-empty list of target interfaces on which the event may fire. All Web IDL interfaces in the list exist in the latest version of the [`@webref/idl` package](https://www.npmjs.com/package/@webref/idl) at the time the `@webref/events` package is released, and represent an actual interface (i.e. not a mixin). diff --git a/package-lock.json b/package-lock.json index f40b534d5cf2..90291cf0cbdc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@octokit/plugin-throttling": "^11.0.1", "@octokit/rest": "22.0.0", "@webref/css": "file:packages/css", + "@webref/css6": "file:packages/css6", "@webref/elements": "file:packages/elements", "@webref/events": "file:packages/events", "@webref/idl": "file:packages/idl", @@ -603,6 +604,10 @@ "resolved": "packages/css", "link": true }, + "node_modules/@webref/css6": { + "resolved": "packages/css6", + "link": true + }, "node_modules/@webref/elements": { "resolved": "packages/elements", "link": true @@ -2995,6 +3000,15 @@ } }, "packages/css": { + "name": "@webref/css", + "version": "7.0.0", + "dev": true, + "license": "MIT", + "peerDependencies": { + "css-tree": "^3.1.0" + } + }, + "packages/css6": { "name": "@webref/css", "version": "6.23.0", "dev": true, @@ -3403,6 +3417,10 @@ "version": "file:packages/css", "requires": {} }, + "@webref/css6": { + "version": "file:packages/css6", + "requires": {} + }, "@webref/elements": { "version": "file:packages/elements" }, diff --git a/package.json b/package.json index 5171afdbef8e..a364e3e7f2eb 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "@octokit/plugin-throttling": "^11.0.1", "@octokit/rest": "22.0.0", "@webref/css": "file:packages/css", + "@webref/css6": "file:packages/css6", "@webref/elements": "file:packages/elements", "@webref/events": "file:packages/events", "@webref/idl": "file:packages/idl", diff --git a/packages/css/CHANGELOG.md b/packages/css/CHANGELOG.md index a93b50e9f1c0..25c7d54b3690 100644 --- a/packages/css/CHANGELOG.md +++ b/packages/css/CHANGELOG.md @@ -7,6 +7,23 @@ Webref adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), applied to data. A new major version is released whenever a breaking change is made to the data structure. +## v7.0.0 - 2025-06 + +CSS extracts are now consolidated into a single file. + +### Breaking changes + +- A single consolidated `css.json` file replaces CSS extracts per spec. + +### How to upgrade + +In version 6, `listAll()` resolved with an object where the keys were spec shortnames, and the values mostly matched the structure of the consolidated object that the function now returns. On top of the consolidation itself, main differences are: +- Functions and types were merged in a `values` category in version 6, they now appear in separate `functions` and `types` categories. +- Functions and types that were scoped to another CSS feature appeared nested under that CSS feature in version 6. They now appear directly under `functions` and `types` with a `for` key that contains the name of the scoping feature. +- The shortname of the spec (or specs) that defines a feature is no longer readily available (but note the `href` key targets the defining spec). If you need the specs' shortnames, please [raise an issue](https://github.com/w3c/webref/issues) to describe your use case. +- The consolidation removes duplicates, merging extended definitions into a single feature. The definition from the latest spec level is used when a feature is defined in more than one level. If you need the definition from earlier levels, please [raise an issue](https://github.com/w3c/webref/issues) to describe your needs! +- Some of the possible values that a CSS feature could take appeared nested under that feature definition in a `values` key in version 6. Such values are no longer reported in the new version: they were confusing in any case because they did not cover the whole range of values that a feature could take, and could contain values that were not atomic keyword values. Values could be re-introduced when CSS specs are more systematic about them. In the meantime, you will need to parse the feature's syntax (the `value` key) to extract keyword values. + ## v6.0.0 - 2022-11-28 diff --git a/packages/css/README.md b/packages/css/README.md index 85c3f207af0e..bb1cd098f382 100644 --- a/packages/css/README.md +++ b/packages/css/README.md @@ -1,46 +1,61 @@ # CSS definitions of the web platform -This package contains CSS property definitions scraped from the latest versions of web platform specifications in [webref](https://github.com/w3c/webref), with fixes applied to ensure ([almost](#guarantees)) all CSS value definitions can be parsed with [CSSTree](https://github.com/csstree/csstree). +This package contains a consolidated list of CSS features defined across specs, scraped from the latest versions of web platform specifications in [webref](https://github.com/w3c/webref). Fixes are applied to ensure that [guarantees](#guarantees) hold, including the ability to parse syntaxes associated with CSS features with [CSSTree](https://github.com/csstree/csstree). + +**Important:** If you're migrating from version 6, see the [changelog](CHANGELOG.md) for "How to upgrade" considerations. # API -The async `listAll()` method resolves with an object where the keys are spec shortnames, and the values are the data for that spec. Example: +The async `listAll()` method resolves with an object that contains lists of features grouped by feature type: `atrules`, `functions`, `properties`, `selectors` and `types`. Example: ```js const css = require('@webref/css'); -const parsedFiles = await css.listAll(); -for (const [shortname, data] of Object.entries(parsedFiles)) { - // do something with the json object +const { atrules, functions, properties, selectors, types } = await css.listAll(); + +for (const feature of functions) { + // do something with the object that describes the CSS function } ``` -CSS fragments that appear in the objects, in other words the contents of the `properties[].value`, `properties[].newValues`, `atrules[].value`, `atrules[].descriptors[].value`, `selectors[].value` and `values[].value` properties can be parsed with the [CSSTree Value Definition Syntax parser](https://github.com/csstree/csstree/blob/master/docs/definition-syntax.md#value-definition-syntax). Example: +Each CSS feature is described by: +- a `name` key that contains the name of the feature +- an `href` key that contains the URL (with a fragment) of the CSS spec that defines the feature + +Many CSS features also have a `value` key that describes the syntax of the feature, as defined in the spec. This syntax can be parsed with the [CSSTree Value Definition Syntax parser](https://github.com/csstree/csstree/blob/master/docs/definition-syntax.md#value-definition-syntax). Example: ```js const css = require('@webref/css'); const { definitionSyntax } = require('css-tree'); -const parsedFiles = await css.listAll(); -for (const [shortname, data] of Object.entries(parsedFiles)) { - for (const property of data.properties) { - if (property.value) { - try { - const ast = definitionSyntax.parse(property.value); - // do something with the ast - } - catch { - // one of the few value definitions that cannot yet be parsed by CSSTree - } - } +const { properties } = await css.listAll(); +for (const property of properties) { + if (!property.value) { + continue; } + const ast = definitionSyntax.parse(property.value); + // do something with the abstract syntax tree } ``` +Additional keys may be set depending on the type of the CSS feature. For example: + +- At-rules have a `descriptors` key that contains the list of descriptors defined for the given at-rule. +- Functions and types that are scoped to a property or other feature have a `for` key that contains the name of the scoping property or other feature. +- Properties have a `styleDeclaration` key that contains the list of IDL attribute names that the property generates. A number of other keys may be set to describe the property's initial value, animation type and other parameters. + +Additional notes: +- Type names are enclosed in `<>`. For example: ``. +- When a feature is defined across different levels in the same spec series, the definition from the latest level is used. +- When a property is extended with new values in different specs, `href` links to the base definition and `value` is the union (using `|`) of the syntaxes of the base and extended definitions. +- When new descriptors are defined for an at-rule in different specs, `descriptors` contains the merged list of known descriptors. +- When specs define the syntax of an at-rule in terms of `` or ``, the `value` key contains an "expanded" syntax that leverages the syntax of the at-rule's descriptors. + # Guarantees The following guarantees are provided by this package: -- All values in CSS files can be parsed by the version of [CSSTree](https://github.com/csstree/csstree) used in `peerDependencies` in `package.json`. -- No duplicate definitions of entries in CSS files provided that CSS extracts of [delta specs](https://github.com/w3c/browser-specs/#seriescomposition) are not taken into account (such extracts end with `-n.json`, where `n` is a level number). The term "entries" includes CSS properties, at-rules, selectors, types and functions. Please note that specs may still extend entries defined elsewhere (to define new values for CSS properties, or new selectors for at-rules). -- CSS extracts contain a base definition of all CSS properties that get extended by other CSS property definitions (those for which `newValues` is set). -- All entries in CSS files that do not extend a base definition link back to their actual definition in the spec. In other words, all entries under `properties[]`, `properties[].values[]`, `selectors[]`, `atrules[]` and `values[]` have an `href` key that contains an absolute URL with fragment, except properties that that have a `newValues` key, at-rules that neither have a `prose` nor a `value` key, and definitions of a [delta spec](https://github.com/w3c/browser-specs/#seriescomposition) that completely override a definition in a previous level. +- All syntax values (the `value` keys) can be parsed by the version of [CSSTree](https://github.com/csstree/csstree) set in `peerDependencies` in `package.json`. +- Feature names (the `name` keys) are unique per type provided that the `for` key is also taken into account for functions and types. +- All features have an `href` key that targets the CSS spec that defines the feature. When the feature is extended across CSS specs, this URL targets the base definition. + +*Note:* there is no guarantee that functions, properties and types referenced by other constructs actually exist. The grammar is known to be incomplete. \ No newline at end of file diff --git a/packages/css/index.js b/packages/css/index.js index 47b478a11b38..ee53d6c6bb70 100644 --- a/packages/css/index.js +++ b/packages/css/index.js @@ -2,15 +2,8 @@ const fs = require('fs').promises; const path = require('path'); async function listAll({folder = __dirname} = {}) { - const all = {}; - const files = await fs.readdir(folder); - for (const f of files) { - if (f.endsWith('.json') && f !== 'package.json') { - const text = await fs.readFile(path.join(folder, f), 'utf8'); - all[path.basename(f, '.json')] = JSON.parse(text); - } - } - return all; + const json = await fs.readFile(path.join(folder, 'css.json'), 'utf8'); + return JSON.parse(json); } module.exports = {listAll}; diff --git a/packages/css/package.json b/packages/css/package.json index 1dd345b732d0..cee511dc6207 100644 --- a/packages/css/package.json +++ b/packages/css/package.json @@ -1,7 +1,7 @@ { "name": "@webref/css", "description": "CSS definitions of the web platform", - "version": "6.23.1", + "version": "7.0.0-alpha", "repository": { "type": "git", "url": "https://github.com/w3c/webref.git" diff --git a/packages/css6/CHANGELOG.md b/packages/css6/CHANGELOG.md new file mode 100644 index 000000000000..a93b50e9f1c0 --- /dev/null +++ b/packages/css6/CHANGELOG.md @@ -0,0 +1,66 @@ +# Changelog + +This file documents breaking changes introduced in major releases of the +`@webref/css` NPM package. + +Webref adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), +applied to data. A new major version is released whenever a breaking change is +made to the data structure. + + +## v6.0.0 - 2022-11-28 + +Major re-write of CSS extracts listed in the package, following the release +of [Reffy v11.0.0](https://github.com/w3c/reffy/blob/main/CHANGELOG.md#v1100---2022-11-28) + +### Breaking changes + +- Arrays are now used throughout instead of indexed objects. +- Function names are no longer enclosed in `<` and `>` because they are not +defined in specs with these characters (as opposed to types). Beware though, +references to functions in value syntax do use enclosing `<` and `>` characters. +- The property `valuespaces` at the root level is now named `values`. An array +is used there as well. The `values` property lists both `function` and `type` +definitions that are not namespaced to anything in particular (it used to also +contain namespaced definitions). + +### Added + +- Selectors are now reported under a `selectors` property at the root level. +- Possible values that some definition may take are now reported under a +`values` property directly within the definition. +- Functions and types that are namespaced to some other definition are included +in the list of `values` of that definition. +- Anomalies detected in the spec are now reported under a `warnings` property at +the root of the extract. Four types of anomalies are reported: + 1. **Missing definition**: when a production rule was found but when the spec + does not include a corresponding `` (or when that `` does not have a + `data-dfn-type` attribute that identifies a CSS construct) + 2. **Duplicate definition**: when the spec defines the same term twice. + 3. **Unmergeable definition**: when the spec defines the same property twice + and both definitions cannot be merged. + 4. **Dangling value**: when the spec defines a CSS "value" definition + (`value`, `function` or `type`) for something and that something cannot be + found in the spec +- To distinguish between `function`, `type` and `value` definitions listed in a +`values` property, definitions that appear in a `values` property have a `type` +property. + +### Additional notes + +- Only namespaced values associated with a definition are listed under its +`values` property. Non-namespaced values are not. For instance, `` is not +listed as a value of the `` type, even though its value syntax +references it. This is to avoid duplicating constructs in the extracts. +- Values are only listed under the deepest definition to which they apply. For +instance, `open-quote` is only listed as a value of `` but neither as a +value of the `` type that references `` nor as a value of +the `content` property that references ``. This is also to avoid +duplicating constructs in the extracts. +- Some of the extracts contain things that may look weird at first, but that is +"by design". For instance, [CSS Will +change](https://drafts.csswg.org/css-will-change-1/) defines a +[``](https://drafts.csswg.org/css-will-change-1/#valdef-will-change-custom-ident) +`value` construct whose actual value is the `` `type` construct +defined in CSS Values. Having both a namespaced `value` and a non-namespaced +`` is somewhat common in CSS specs. diff --git a/packages/css6/README.md b/packages/css6/README.md new file mode 100644 index 000000000000..85c3f207af0e --- /dev/null +++ b/packages/css6/README.md @@ -0,0 +1,46 @@ +# CSS definitions of the web platform + +This package contains CSS property definitions scraped from the latest versions of web platform specifications in [webref](https://github.com/w3c/webref), with fixes applied to ensure ([almost](#guarantees)) all CSS value definitions can be parsed with [CSSTree](https://github.com/csstree/csstree). + +# API + +The async `listAll()` method resolves with an object where the keys are spec shortnames, and the values are the data for that spec. Example: + +```js +const css = require('@webref/css'); + +const parsedFiles = await css.listAll(); +for (const [shortname, data] of Object.entries(parsedFiles)) { + // do something with the json object +} +``` + +CSS fragments that appear in the objects, in other words the contents of the `properties[].value`, `properties[].newValues`, `atrules[].value`, `atrules[].descriptors[].value`, `selectors[].value` and `values[].value` properties can be parsed with the [CSSTree Value Definition Syntax parser](https://github.com/csstree/csstree/blob/master/docs/definition-syntax.md#value-definition-syntax). Example: + +```js +const css = require('@webref/css'); +const { definitionSyntax } = require('css-tree'); + +const parsedFiles = await css.listAll(); +for (const [shortname, data] of Object.entries(parsedFiles)) { + for (const property of data.properties) { + if (property.value) { + try { + const ast = definitionSyntax.parse(property.value); + // do something with the ast + } + catch { + // one of the few value definitions that cannot yet be parsed by CSSTree + } + } + } +} +``` + +# Guarantees + +The following guarantees are provided by this package: +- All values in CSS files can be parsed by the version of [CSSTree](https://github.com/csstree/csstree) used in `peerDependencies` in `package.json`. +- No duplicate definitions of entries in CSS files provided that CSS extracts of [delta specs](https://github.com/w3c/browser-specs/#seriescomposition) are not taken into account (such extracts end with `-n.json`, where `n` is a level number). The term "entries" includes CSS properties, at-rules, selectors, types and functions. Please note that specs may still extend entries defined elsewhere (to define new values for CSS properties, or new selectors for at-rules). +- CSS extracts contain a base definition of all CSS properties that get extended by other CSS property definitions (those for which `newValues` is set). +- All entries in CSS files that do not extend a base definition link back to their actual definition in the spec. In other words, all entries under `properties[]`, `properties[].values[]`, `selectors[]`, `atrules[]` and `values[]` have an `href` key that contains an absolute URL with fragment, except properties that that have a `newValues` key, at-rules that neither have a `prose` nor a `value` key, and definitions of a [delta spec](https://github.com/w3c/browser-specs/#seriescomposition) that completely override a definition in a previous level. diff --git a/packages/css6/index.js b/packages/css6/index.js new file mode 100644 index 000000000000..47b478a11b38 --- /dev/null +++ b/packages/css6/index.js @@ -0,0 +1,16 @@ +const fs = require('fs').promises; +const path = require('path'); + +async function listAll({folder = __dirname} = {}) { + const all = {}; + const files = await fs.readdir(folder); + for (const f of files) { + if (f.endsWith('.json') && f !== 'package.json') { + const text = await fs.readFile(path.join(folder, f), 'utf8'); + all[path.basename(f, '.json')] = JSON.parse(text); + } + } + return all; +} + +module.exports = {listAll}; diff --git a/packages/css6/package.json b/packages/css6/package.json new file mode 100644 index 000000000000..c0ca0733b246 --- /dev/null +++ b/packages/css6/package.json @@ -0,0 +1,17 @@ +{ + "name": "@webref/css", + "description": "CSS definitions of the web platform", + "version": "6.23.0", + "repository": { + "type": "git", + "url": "https://github.com/w3c/webref.git" + }, + "bugs": { + "url": "https://github.com/w3c/webref/issues" + }, + "license": "MIT", + "main": "index.js", + "peerDependencies": { + "css-tree": "^3.1.0" + } +} \ No newline at end of file diff --git a/test/css/all.js b/test/css/all.js index 7a2447fb5022..e9755f794b76 100644 --- a/test/css/all.js +++ b/test/css/all.js @@ -11,7 +11,7 @@ import { describe, it } from 'node:test'; import { strict as assert } from 'node:assert'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; -import css from '@webref/css'; +import css from '@webref/css6'; import index from '../../curated/index.json' with { type: 'json' }; import { definitionSyntax } from 'css-tree'; import { study } from 'strudy'; diff --git a/test/css/consolidated.js b/test/css/consolidated.js index acefcf72f1bf..528e3bb1d24b 100644 --- a/test/css/consolidated.js +++ b/test/css/consolidated.js @@ -4,9 +4,15 @@ import { describe, it } from 'node:test'; import { strict as assert } from 'node:assert'; -import consolidated from '../../curated/css.json' with { type: 'json' }; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import css from '@webref/css'; import { definitionSyntax } from 'css-tree'; +const scriptPath = path.dirname(fileURLToPath(import.meta.url)); +const curatedFolder = path.join(scriptPath, '..', '..', 'curated'); + + // Expected categories in the consolidated file const categories = { atrules: 'at-rule', @@ -27,6 +33,15 @@ function pluralize(word) { } describe(`The consolidated CSS file`, async () => { + // Create a set of well-known interfaces and an inheritance chain + let consolidated; + try { + consolidated = await css.listAll({ folder: curatedFolder }); + } + catch (err) { + it('contains valid JSON', () => { throw err; }); + } + for (const [category, label] of Object.entries(categories)) { const list = consolidated[category]; diff --git a/tools/bump-packages-minor.js b/tools/bump-packages-minor.js index db4f8074e770..3b7ae8bb6aed 100644 --- a/tools/bump-packages-minor.js +++ b/tools/bump-packages-minor.js @@ -30,11 +30,12 @@ async function checkPackage(type) { // Loosely adapted from semver: // https://github.com/npm/node-semver/blob/cb1ca1d5480a6c07c12ac31ba5f2071ed530c4ed/internal/re.js#L37 // (not using semver directly to avoid having to install dependencies in job) - const reVersion = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/; + const reVersion = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-.+)?$/; const versionTokens = version.match(reVersion); const major = parseInt(versionTokens[1], 10); const minor = parseInt(versionTokens[2], 10); const patch = parseInt(versionTokens[3], 10); + const alpha = versionTokens[4] ?? ''; if (patch === 0) { console.log('- No bump needed, minor bump already pending'); @@ -46,7 +47,7 @@ async function checkPackage(type) { { encoding: 'utf8' }).trim(); if (res) { console.log('- new/deleted files found'); - const newVersion = `${major}.${minor+1}.0`; + const newVersion = `${major}.${minor+1}.0${alpha}`; packageContents.version = newVersion; fs.writeFile(packageFile, JSON.stringify(packageContents, null, 2), 'utf8'); console.log(`- Version bumped to ${newVersion}`); diff --git a/tools/prepare-packages.js b/tools/prepare-packages.js index 8971e4fd5447..1a76e9b18be2 100644 --- a/tools/prepare-packages.js +++ b/tools/prepare-packages.js @@ -27,7 +27,8 @@ async function preparePackages(curatedFolder, packagesFolder) { console.log(`- ${crawlIndex.results.length} curated specs in index file`); const packages = [ - { name: 'css', fileExt: 'json' }, + { name: 'css', fileExt: 'json', index: 'css.json', folder: null }, + { name: 'css6', fileExt: 'json', folder: 'css' }, { name: 'elements', fileExt: 'json' }, { name: 'events', fileExt: 'json', index: 'events.json', folder: null }, { name: 'idl', fileExt: 'idl' } diff --git a/tools/prepare-release.js b/tools/prepare-release.js index 9f639c41827a..b470141f41de 100644 --- a/tools/prepare-release.js +++ b/tools/prepare-release.js @@ -62,15 +62,19 @@ MissingPackageError.prototype = Error.prototype; * match. */ async function computeDiff(type) { + const packageName = type.replace(/\d+$/, ''); + const majorVersionMatch = type.match(/(\d+)$/); + const majorVersion = majorVersionMatch ? '@' + majorVersionMatch[1] : ''; + // Install @webref package in tmp folder const tmpFolder = fs.mkdtempSync(path.join(os.tmpdir(), "webref-")); try { - execSync(`npm install @webref/${type}`, { + execSync(`npm install @webref/${packageName}${majorVersion}`, { cwd: tmpFolder }); } catch (err) { - throw new MissingPackageError(`Package @webref/${type} does not exist or could not be installed.`); + throw new MissingPackageError(`Package @webref/${packageName}${majorVersion} does not exist or could not be installed.`); } // Extract released version (will be used in the body of the pre-release PR) @@ -161,7 +165,8 @@ async function computeDiff(type) { * * @function * @param {String} type Package name. Must match one of the existing folder - * names under "packages" (e.g. "css", "elements", "events", "idl") + * names under "packages" (e.g. "css", "elements", "events", "idl"), possibly + * pinned to a major version. */ async function prepareRelease(type) { // Compute a reasonably unique ID @@ -243,11 +248,14 @@ ${diff.substring(0, 60000)}`; console.log("Extract and bump version number"); const packageFilename = path.resolve(scriptPath, '..', 'packages', type, 'package.json'); const packageFile = await loadJSON(packageFilename); - const version = packageFile.version; + const fullVersion = packageFile.version; + const versionTokens = version.match(/^([\d\.]+)(-.+)?$/); + const version = versionTokens[1]; + const alpha = versionTokens[2] ?? ''; const bumpedVersion = version .split(".") .map((nb, idx) => parseInt(nb, 10) + ((idx === 2) ? 1 : 0)) - .join("."); + .join(".") + alpha; packageFile.version = bumpedVersion; const bumpedPackageFileContents = btoa(JSON.stringify(packageFile, null, 2)); console.log(`- Version to release: ${version}`); diff --git a/tools/release-package.js b/tools/release-package.js index cde73db2f6f7..3ddb32823e31 100644 --- a/tools/release-package.js +++ b/tools/release-package.js @@ -43,7 +43,7 @@ async function releasePackage(prNumber) { } const type = match[1]; - if (!["css", "elements", "events", "idl"].includes(type)) { + if (!["css", "css6", "elements", "events", "idl"].includes(type)) { console.log(`- Unknown package type "${type}", nothing to release`); return; }