Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into ido/cli-flakiness
Browse files Browse the repository at this point in the history
  • Loading branch information
idoros committed Aug 10, 2022
2 parents 017e788 + 5609827 commit 5c6b822
Show file tree
Hide file tree
Showing 54 changed files with 1,524 additions and 902 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ jobs:
tests:
name: node ${{ matrix.node-version }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
Expand Down
1,366 changes: 727 additions & 639 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
"prettify": "npx prettier . --write"
},
"devDependencies": {
"@file-services/memory": "^6.0.0",
"@file-services/node": "^6.0.0",
"@file-services/memory": "^7.0.1",
"@file-services/node": "^7.0.1",
"@rollup/plugin-html": "^0.2.4",
"@rollup/plugin-node-resolve": "^13.3.0",
"@types/balanced-match": "^1.0.2",
"@types/chai": "^4.3.1",
"@types/chai": "^4.3.3",
"@types/chai-subset": "^1.3.3",
"@types/css-selector-tokenizer": "^0.7.1",
"@types/cssesc": "^3.0.0",
Expand All @@ -31,57 +31,57 @@
"@types/find-config": "^1.0.1",
"@types/flat": "^5.0.2",
"@types/js-beautify": "^1.13.3",
"@types/jsdom": "^16.2.14",
"@types/jsdom": "^20.0.0",
"@types/json-schema": "^7.0.11",
"@types/lodash.camelcase": "^4.3.7",
"@types/lodash.clonedeep": "^4.5.7",
"@types/lodash.clonedeepwith": "^4.5.7",
"@types/lodash.findlast": "^4.6.7",
"@types/lodash.upperfirst": "^4.3.7",
"@types/memory-fs": "^0.3.3",
"@types/mime": "^2.0.3",
"@types/mime": "^3.0.1",
"@types/mocha": "^9.1.1",
"@types/node": "14",
"@types/postcss-safe-parser": "^5.0.1",
"@types/react": "^18.0.15",
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@types/rimraf": "^3.0.2",
"@types/validate-npm-package-name": "^4.0.0",
"@types/yargs": "^17.0.10",
"@typescript-eslint/eslint-plugin": "^5.30.7",
"@typescript-eslint/parser": "^5.30.7",
"autoprefixer": "^10.4.7",
"@types/yargs": "^17.0.11",
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"autoprefixer": "^10.4.8",
"chai": "^4.3.6",
"chai-subset": "^1.6.0",
"create-listening-server": "^1.0.0",
"eslint": "^8.20.0",
"eslint": "^8.21.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"express": "^4.18.1",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.5.0",
"jsdom": "^19.0.0",
"jsdom": "^20.0.0",
"mini-css-extract-plugin": "^2.6.1",
"mocha": "^10.0.0",
"mocha-play": "^3.1.0",
"node-eval": "^2.0.0",
"npm-run-all": "^4.1.5",
"playwright-chromium": "^1.23.4",
"postcss": "^8.4.14",
"playwright-chromium": "^1.24.2",
"postcss": "^8.4.16",
"promise-assist": "^1.3.0",
"raw-loader": "^4.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^3.0.2",
"rollup": "^2.77.0",
"rollup": "^2.77.2",
"source-map": "^0.7.4",
"source-map-loader": "^4.0.0",
"style-loader": "^3.3.1",
"ts-expect": "^1.3.0",
"typescript": "~4.7.4",
"url-loader": "^4.1.1",
"webpack": "^5.73.0",
"webpack": "^5.74.0",
"yargs": "^17.5.1"
},
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions packages/build-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@stylable/build-tools",
"version": "5.0.1",
"version": "5.1.0",
"description": "Collection of helper functions for Stylable based tooling.",
"main": "dist/index.js",
"scripts": {
"test": "mocha \"./dist/test/**/*.spec.js\" --timeout 20000"
},
"dependencies": {
"@stylable/core": "^5.0.1",
"@stylable/core": "^5.1.0",
"find-config": "^1.0.0"
},
"files": [
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class Generator extends Base {
}
protected generateIndexSource(indexFileTargetPath: string) {
const source = super.generateIndexSource(indexFileTargetPath);
return '@namespace "INDEX";\n' + source;
return '@st-namespace "INDEX";\n' + source;
}
}
```
Expand Down Expand Up @@ -338,6 +338,8 @@ npx -p @stylable/cli stc-codemod --help
- `st-global-custom-property-to-at-property` - Convert deprecated `@st-global-custom-property *;` to `@property st-global(*);` syntax.

- `namespace-to-st-namespace` - Converts `@namespace` that would have been used as Stylable namespace configuration to `@st-namespace`.

### Provide an external codemod

Codemods are transformation operations for code based on AST.
Expand Down
18 changes: 9 additions & 9 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stylable/cli",
"version": "5.0.1",
"version": "5.1.0",
"description": "A low-level utility used for working with Stylable projects",
"main": "dist/index.js",
"bin": {
Expand All @@ -12,14 +12,14 @@
"test": "mocha \"./dist/test/**/*.spec.js\" --timeout 25000"
},
"dependencies": {
"@file-services/node": "^6.0.0",
"@file-services/types": "^6.0.0",
"@stylable/build-tools": "^5.0.1",
"@stylable/code-formatter": "^5.0.1",
"@stylable/core": "^5.0.1",
"@stylable/module-utils": "^5.0.1",
"@stylable/node": "^5.0.1",
"@stylable/optimizer": "^5.0.1",
"@file-services/node": "^7.0.1",
"@file-services/types": "^7.0.1",
"@stylable/build-tools": "^5.1.0",
"@stylable/code-formatter": "^5.1.0",
"@stylable/core": "^5.1.0",
"@stylable/module-utils": "^5.1.0",
"@stylable/node": "^5.1.0",
"@stylable/optimizer": "^5.1.0",
"@wixc3/resolve-directory-context": "^3.0.0",
"decache": "^4.6.1",
"lodash.camelcase": "^4.3.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/code-mods/load-codemods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import type { Log } from '../logger';
// Builtin codemods
import { stImportToAtImport } from './st-import-to-at-import';
import { stGlobalCustomPropertyToAtProperty } from './st-global-custom-property-to-at-property';
import { namespaceToStNamespace } from './namespace-to-st-namespace';

export const registeredMods: Map<string, CodeMod> = new Map([
['st-import-to-at-import', stImportToAtImport],
['st-global-custom-property-to-at-property', stGlobalCustomPropertyToAtProperty],
['namespace-to-st-namespace', namespaceToStNamespace],
]);

export function loadBuiltInCodemods(
Expand Down
29 changes: 29 additions & 0 deletions packages/cli/src/code-mods/namespace-to-st-namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { parseNamespace } from '@stylable/core/dist/features/st-namespace';
import type * as postcss from 'postcss';
import type { CodeMod } from './types';

export const namespaceToStNamespace: CodeMod = ({ ast }) => {
let changed = false;
let foundStNamespace = false;
const nodesToMod: postcss.AtRule[] = [];
ast.walkAtRules((atRule) => {
if (atRule.name === 'namespace') {
const namespace = parseNamespace(atRule);
if (namespace) {
nodesToMod.push(atRule);
}
} else if (atRule.name === 'st-namespace') {
foundStNamespace = true;
}
});
if (!foundStNamespace) {
for (const atRule of nodesToMod) {
atRule.name = 'st-namespace';
changed = true;
}
}

return {
changed,
};
};
58 changes: 58 additions & 0 deletions packages/cli/test/codemods/namespace-to-st-namespace.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { expect } from 'chai';
import {
populateDirectorySync,
loadDirSync,
runCliCodeMod,
createTempDirectory,
ITempDirectory,
} from '@stylable/e2e-test-kit';

describe('CLI Codemods namespace-to-st-namespace', () => {
let tempDir: ITempDirectory;

beforeEach(async () => {
tempDir = await createTempDirectory();
});
afterEach(async () => {
await tempDir.remove();
});

it('should replace @namespace with @st-namespace', () => {
populateDirectorySync(tempDir.path, {
'package.json': `{"name": "test", "version": "0.0.0"}`,
'style.st.css': `@namespace "button";`,
});

runCliCodeMod(['--rootDir', tempDir.path, '--mods', 'namespace-to-st-namespace']);

const dirContent = loadDirSync(tempDir.path);

expect(dirContent['style.st.css']).equal('@st-namespace "button";');
});
it('should not replace @namespace when @st-namespace already exist', () => {
populateDirectorySync(tempDir.path, {
'package.json': `{"name": "test", "version": "0.0.0"}`,
'style.st.css': `@namespace "button"; @st-namespace "comp";`,
});

runCliCodeMod(['--rootDir', tempDir.path, '--mods', 'namespace-to-st-namespace']);

const dirContent = loadDirSync(tempDir.path);

expect(dirContent['style.st.css']).equal('@namespace "button"; @st-namespace "comp";');
});
it('should not replace @namespace that would not be used as @st-namespace', () => {
populateDirectorySync(tempDir.path, {
'package.json': `{"name": "test", "version": "0.0.0"}`,
'style.st.css': `@namespace "http://button"; @namespace prefix "btn";`,
});

runCliCodeMod(['--rootDir', tempDir.path, '--mods', 'namespace-to-st-namespace']);

const dirContent = loadDirSync(tempDir.path);

expect(dirContent['style.st.css']).equal(
'@namespace "http://button"; @namespace prefix "btn";'
);
});
});
2 changes: 1 addition & 1 deletion packages/cli/test/fixtures/named-exports-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export class Generator extends IndexGenerator {
}
protected generateIndexSource() {
const source = super.generateIndexSource();
return '@namespace "INDEX";\n' + source;
return '@st-namespace "INDEX";\n' + source;
}
}
4 changes: 2 additions & 2 deletions packages/cli/test/generate-index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ describe('build index', () => {
':import {-st-from: "./comp-A.st.css";-st-default:Style0;}\n.root Style0{}'
);
});
it('should create index file using a custom generator with named exports generation and @namespace', async () => {
it('should create index file using a custom generator with named exports generation and @st-namespace', async () => {
const fs = createMemoryFs({
'/comp-A.st.css': `
:vars {
Expand Down Expand Up @@ -353,7 +353,7 @@ describe('build index', () => {

expect(res.trim()).to.equal(
[
'@namespace "INDEX";',
'@st-namespace "INDEX";',
':import {-st-from: "./comp-A.st.css";-st-default:CompA;-st-named: a as CompA__a, color1 as CompA__color1, --color2 as --CompA__color2, keyframes(X as CompA__X);}',
'.root CompA{}',
'.root .CompA__a{}',
Expand Down
6 changes: 3 additions & 3 deletions packages/code-formatter/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@stylable/code-formatter",
"version": "5.0.1",
"version": "5.1.0",
"description": "A code formatting utility for Stylable stylesheets",
"main": "dist/index.js",
"scripts": {
"test": "mocha \"./dist/test/**/*.spec.js\""
},
"dependencies": {
"@stylable/core": "^5.0.1",
"js-beautify": "^1.14.4"
"@stylable/core": "^5.1.0",
"js-beautify": "^1.14.5"
},
"files": [
"dist",
Expand Down
8 changes: 4 additions & 4 deletions packages/core-test-kit/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "@stylable/core-test-kit",
"version": "5.0.1",
"version": "5.1.0",
"description": "Stylable core test-kit",
"main": "dist/index.js",
"scripts": {
"test": "mocha \"./dist/test/**/*.spec.js\""
},
"dependencies": {
"@file-services/memory": "^6.0.0",
"@stylable/core": "^5.0.1",
"@file-services/memory": "^7.0.1",
"@stylable/core": "^5.1.0",
"chai": "^4.3.6",
"flat": "^5.0.2",
"postcss": "^8.4.14"
"postcss": "^8.4.16"
},
"files": [
"dist",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stylable/core",
"version": "5.0.1",
"version": "5.1.0",
"description": "CSS for Components",
"main": "dist/index.js",
"scripts": {
Expand All @@ -21,7 +21,7 @@
"is-vendor-prefixed": "^4.0.0",
"lodash.clonedeep": "^4.5.0",
"lodash.clonedeepwith": "^4.5.0",
"postcss": "^8.4.14",
"postcss": "^8.4.16",
"postcss-js": "^4.0.0",
"postcss-nested": "^5.0.6",
"postcss-safe-parser": "^6.0.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export type { StylableSymbol } from './st-symbol';
export * as STImport from './st-import';
export type { ImportSymbol, Imported } from './st-import';

export * as STNamespace from './st-namespace';

export * as STGlobal from './st-global';

export * as STScope from './st-scope';
Expand Down
Loading

0 comments on commit 5c6b822

Please sign in to comment.