diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /scripts/frontend | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'scripts/frontend')
-rwxr-xr-x | scripts/frontend/graphql_possible_types_extraction.js | 69 | ||||
-rw-r--r-- | scripts/frontend/startup_css/constants.js | 2 | ||||
-rw-r--r-- | scripts/frontend/stylelint/stylelint_duplicate_selectors.js (renamed from scripts/frontend/stylelint/stylelint-duplicate-selectors.js) | 2 | ||||
-rw-r--r-- | scripts/frontend/stylelint/stylelint_utility_classes.js (renamed from scripts/frontend/stylelint/stylelint-utility-classes.js) | 4 | ||||
-rw-r--r-- | scripts/frontend/stylelint/stylelint_utility_map.js (renamed from scripts/frontend/stylelint/stylelint-utility-map.js) | 6 | ||||
-rw-r--r-- | scripts/frontend/stylelint/stylelint_utils.js (renamed from scripts/frontend/stylelint/stylelint-utils.js) | 0 | ||||
-rw-r--r-- | scripts/frontend/stylelint/utility_classes_map.js (renamed from scripts/frontend/stylelint/utility-classes-map.js) | 0 |
7 files changed, 76 insertions, 7 deletions
diff --git a/scripts/frontend/graphql_possible_types_extraction.js b/scripts/frontend/graphql_possible_types_extraction.js new file mode 100755 index 00000000000..61f783086e7 --- /dev/null +++ b/scripts/frontend/graphql_possible_types_extraction.js @@ -0,0 +1,69 @@ +#!/usr/bin/env node + +const fs = require('fs/promises'); +const path = require('path'); +const assert = require('assert'); + +const ROOT_DIR = path.join(__dirname, '../../'); +const GRAPHQL_SCHEMA = path.join(ROOT_DIR, 'tmp/tests/graphql/gitlab_schema.json'); +const POSSIBLE_TYPES_REL = 'app/assets/javascripts/graphql_shared/possible_types.json'; +const POSSIBLE_TYPES = path.join(ROOT_DIR, POSSIBLE_TYPES_REL); + +function extractTypes(schema) { + return Object.fromEntries( + // eslint-disable-next-line no-underscore-dangle + schema.data.__schema.types + .filter((type) => type.possibleTypes) + .map(({ name, possibleTypes }) => [name, possibleTypes.map((subtype) => subtype.name)]), + ); +} + +async function main() { + let schema; + try { + schema = JSON.parse(await fs.readFile(GRAPHQL_SCHEMA, 'utf-8')); + } catch (e) { + console.error( + 'Could not read the GraphQL Schema, make sure to run: bundle exec rake gitlab:graphql:schema:dump', + ); + throw e; + } + + const possibleTypes = extractTypes(schema); + + if (process.argv.includes('--check')) { + const previousTypes = JSON.parse(await fs.readFile(POSSIBLE_TYPES, 'utf-8')); + + assert.deepStrictEqual( + previousTypes, + possibleTypes, + ` +${POSSIBLE_TYPES_REL} needs to be regenerated, please run: + node scripts/frontend/graphql_possible_types_extraction.js --write +and commit the changes! + `, + ); + return; + } + + if (process.argv.includes('--write')) { + const stringifiedPossibleTypes = JSON.stringify(possibleTypes, null, 2); + await fs.writeFile(POSSIBLE_TYPES, `${stringifiedPossibleTypes}\n`); + console.log(`Successfully updated ${POSSIBLE_TYPES_REL}`); + return; + } + + throw new Error(` +ERROR: Please use the script correctly: +Usage: graphql_possible_types_extraction [options] + +Options: + --check Check whether there are new Interface or Union types + --write Generate new possible types + `); +} + +main().catch((error) => { + console.warn(error.message); + process.exitCode = 1; +}); diff --git a/scripts/frontend/startup_css/constants.js b/scripts/frontend/startup_css/constants.js index 83f43143e1b..10d60657e09 100644 --- a/scripts/frontend/startup_css/constants.js +++ b/scripts/frontend/startup_css/constants.js @@ -50,7 +50,7 @@ const createMainOutput = ({ outFile, cssKeys, type }) => ({ htmlPaths: [ path.join(FIXTURES_ROOT, `startup_css/project-${type}.html`), path.join(FIXTURES_ROOT, `startup_css/project-${type}-signed-out.html`), - path.join(FIXTURES_ROOT, `startup_css/project-${type}-search-ff-on.html`), + path.join(FIXTURES_ROOT, `startup_css/project-${type}-search-ff-off.html`), ], cssKeys, purgeOptions: { diff --git a/scripts/frontend/stylelint/stylelint-duplicate-selectors.js b/scripts/frontend/stylelint/stylelint_duplicate_selectors.js index 982ddf524a3..77c1f1292b7 100644 --- a/scripts/frontend/stylelint/stylelint-duplicate-selectors.js +++ b/scripts/frontend/stylelint/stylelint_duplicate_selectors.js @@ -1,5 +1,5 @@ const stylelint = require('stylelint'); -const utils = require('./stylelint-utils'); +const utils = require('./stylelint_utils'); const ruleName = 'stylelint-gitlab/duplicate-selectors'; diff --git a/scripts/frontend/stylelint/stylelint-utility-classes.js b/scripts/frontend/stylelint/stylelint_utility_classes.js index 14827145b54..ad2b2ddbb20 100644 --- a/scripts/frontend/stylelint/stylelint-utility-classes.js +++ b/scripts/frontend/stylelint/stylelint_utility_classes.js @@ -1,6 +1,6 @@ const stylelint = require('stylelint'); -const utils = require('./stylelint-utils'); -const utilityClasses = require('./utility-classes-map'); +const utils = require('./stylelint_utils'); +const utilityClasses = require('./utility_classes_map'); const ruleName = 'stylelint-gitlab/utility-classes'; diff --git a/scripts/frontend/stylelint/stylelint-utility-map.js b/scripts/frontend/stylelint/stylelint_utility_map.js index 676f83cd067..187b2065823 100644 --- a/scripts/frontend/stylelint/stylelint-utility-map.js +++ b/scripts/frontend/stylelint/stylelint_utility_map.js @@ -4,13 +4,13 @@ const postcss = require('postcss'); const prettier = require('prettier'); const sass = require('sass'); -const utils = require('./stylelint-utils'); +const utils = require('./stylelint_utils'); const ROOT_PATH = path.resolve(__dirname, '../../..'); -const hashMapPath = path.resolve(__dirname, './utility-classes-map.js'); +const hashMapPath = path.resolve(__dirname, './utility_classes_map.js'); // -// This creates a JS based hash map (saved in utility-classes-map.js) of the different values in the utility classes +// This creates a JS based hash map (saved in utility_classes_map.js) of the different values in the utility classes // sass.render( { diff --git a/scripts/frontend/stylelint/stylelint-utils.js b/scripts/frontend/stylelint/stylelint_utils.js index c9d9c7d9aad..c9d9c7d9aad 100644 --- a/scripts/frontend/stylelint/stylelint-utils.js +++ b/scripts/frontend/stylelint/stylelint_utils.js diff --git a/scripts/frontend/stylelint/utility-classes-map.js b/scripts/frontend/stylelint/utility_classes_map.js index a174812ff93..a174812ff93 100644 --- a/scripts/frontend/stylelint/utility-classes-map.js +++ b/scripts/frontend/stylelint/utility_classes_map.js |