Skip to content

Commit

Permalink
Merge pull request #486 from ice-lab/release-next
Browse files Browse the repository at this point in the history
Release @ice/pkg@1.5.3
  • Loading branch information
luhc228 authored Feb 28, 2023
2 parents 20d7437 + 06e270b commit bca916d
Show file tree
Hide file tree
Showing 63 changed files with 5,599 additions and 676 deletions.
2 changes: 2 additions & 0 deletions examples/rax-component/__mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module.exports = {};

16 changes: 16 additions & 0 deletions examples/rax-component/babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"presets": [
[
"@babel/preset-typescript",
{
"onlyRemoveTypeImports": true
}
],
["@babel/preset-env", {
"loose": true
}],
["@babel/preset-react", {
"pragma": "createElement"
}]
]
}
5 changes: 5 additions & 0 deletions examples/rax-component/enzyme-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-rax';

// Setup Enzyme
enzyme.configure({ adapter: new Adapter() });
9 changes: 9 additions & 0 deletions examples/rax-component/jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pkgService, { defineJestConfig } from '@ice/pkg';

export default defineJestConfig(pkgService, {
setupFilesAfterEnv: ['<rootDir>/enzyme-setup.ts'],
moduleNameMapper: {
'\\.(css|less|scss)$': '<rootDir>/__mocks__/styleMock.js',
},
transformIgnorePatterns: ['<rootDir>/node_modules/rax-*'],
});
17 changes: 15 additions & 2 deletions examples/rax-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"eslint": "eslint --cache --ext .js,.jsx,.ts,.tsx ./",
"eslint:fix": "npm run eslint -- --fix",
"stylelint": "stylelint \"**/*.{css,scss,less}\"",
"lint": "npm run eslint && npm run stylelint"
"lint": "npm run eslint && npm run stylelint",
"test": "jest"
},
"keywords": [
"ice",
Expand All @@ -47,15 +48,27 @@
],
"dependencies": {
"@swc/helpers": "^0.4.14",
"babel-runtime-jsx-plus": "^0.1.5"
"babel-runtime-jsx-plus": "^0.1.5",
"rax-view": "^2.3.0"
},
"devDependencies": {
"@babel/core": "^7.17.5",
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@ice/pkg": "workspace:*",
"@ice/pkg-plugin-docusaurus": "workspace:*",
"@ice/pkg-plugin-jsx-plus": "workspace:*",
"@ice/pkg-plugin-rax-component": "workspace:*",
"@testing-library/jest-dom": "^5.16.5",
"@types/enzyme": "^3.10.12",
"@types/rax": "^1.0.0",
"@types/testing-library__jest-dom": "^5.14.5",
"enzyme": "^3.11.0",
"enzyme-adapter-rax": "^1.0.3",
"jest": "^28.0.0",
"rax": "^1.2.2",
"rax-test-renderer": "^1.1.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
Expand Down
3 changes: 3 additions & 0 deletions examples/rax-component/src/components/Header/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
div {
color: red
}
9 changes: 9 additions & 0 deletions examples/rax-component/src/components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createElement } from 'rax';
import View from 'rax-view';
import './index.css';

export default function Header() {
return (
<View data-testid="header">Header</View>
);
}
7 changes: 5 additions & 2 deletions examples/rax-component/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createElement, Fragment } from 'rax';
import styles from './index.module.css';
import Header from './components/Header';

interface ComponentProps {
/** Title for ExampleRaxComponent. */
Expand All @@ -8,12 +9,14 @@ interface ComponentProps {

export default function ExampleRaxComponent(props: ComponentProps) {
const { title = 'Hello World!' } = props;

console.log(__DEV__);
const role = 'admin';
return (
<div className={styles.ExampleRaxComponent}>
<Header />
{title}
<>xxxxxxxx</>
<div x-if={true}>admin</div>
<div x-if={role === 'admin'}>admin</div>
<div x-else>guest</div>
</div>
);
Expand Down
8 changes: 8 additions & 0 deletions examples/rax-component/tests/Header.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createElement } from 'rax';
import renderer from 'rax-test-renderer';
import Header from '../src/components/Header';

test('test <Button /> component', () => {
const tree = renderer.create(<Header />);
expect(tree.toJSON().children[0]).toBe('Header')
});
2 changes: 2 additions & 0 deletions examples/rax-component/tests/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare module 'rax-test-renderer';
declare module 'enzyme-adapter-rax';
5 changes: 3 additions & 2 deletions examples/rax-component/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"skipLibCheck": true
"skipLibCheck": true,
"types": ["vitest/globals"]
},
"include": ["src"],
"include": ["src", "tests"],
}
2 changes: 2 additions & 0 deletions examples/react-component/__mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module.exports = {};

2 changes: 1 addition & 1 deletion examples/react-component/build.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export default defineConfig({
transform: {
formats: ['esm', 'es2017'],
},
jsxRuntime: 'classic',
sourceMaps: false,
bundle: {
formats: ['esm', 'es2017'],
minify: false,
development: true,
},
alias: {
Expand Down
1 change: 1 addition & 0 deletions examples/react-component/jest-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom';
11 changes: 11 additions & 0 deletions examples/react-component/jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pkgService, { defineJestConfig } from '@ice/pkg';

export default defineJestConfig(pkgService, {
preset: 'ts-jest',
setupFilesAfterEnv: ['<rootDir>/jest-setup.ts'],
testEnvironment: 'jest-environment-jsdom',
moduleNameMapper: {
'\\.module\\.(css|scss|less)$': 'identity-obj-proxy',
'\\.(css|less|scss)$': '<rootDir>/__mocks__/styleMock.js',
},
});
17 changes: 15 additions & 2 deletions examples/react-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"scripts": {
"start": "ice-pkg start",
"build": "ice-pkg build",
"prepublishOnly": "npm run build"
"prepublishOnly": "npm run build",
"vitest": "vitest",
"jest": "jest"
},
"dependencies": {
"@ice/jsx-runtime": "^0.2.0",
Expand All @@ -37,11 +39,22 @@
"@ice/pkg": "workspace:*",
"@ice/pkg-plugin-docusaurus": "workspace:*",
"@ice/pkg-plugin-jsx-plus": "workspace:*",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@types/testing-library__jest-dom": "^5.14.5",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.0.0",
"jest-environment-jsdom": "^29.0.0",
"jsdom": "^21.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"style-unit": "^3.0.4"
"sass": "^1.58.3",
"sass-loader": "^13.2.0",
"style-unit": "^3.0.4",
"ts-jest": "^29.0.0",
"vitest": "^0.28.5"
},
"peerDependencies": {
"react": "^17 || ^18"
Expand Down
3 changes: 2 additions & 1 deletion examples/react-component/src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as React from 'react';
import styles from './index.module.scss';

interface ButtonProps {
onClick?: React.MouseEventHandler;
}

const Button: React.FunctionComponent<React.PropsWithChildren<ButtonProps>> = (props) => {
return (
<button onClick={props.onClick}>{props.children}</button>
<button className={styles.button} onClick={props.onClick} data-testid="normal-button">{props.children}</button>
);
};

Expand Down
3 changes: 3 additions & 0 deletions examples/react-component/src/components/index.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.button {
background: lightskyblue;
}
4 changes: 4 additions & 0 deletions examples/react-component/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* This is comment */
.title {
color: red;
}
3 changes: 2 additions & 1 deletion examples/react-component/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import Button from '@/components/Button';
import './index.css';

export default function Component() {
console.log(__DEV__);
Expand All @@ -8,7 +9,7 @@ export default function Component() {
const [visible, setVisible] = React.useState(false);
return (
<>
<h1 style={{ fontSize: '100rpx' }}>Hello World</h1>
<h1 style={{ fontSize: '100rpx' }} data-testid="title">Hello World</h1>
<Button onClick={() => setVisible(!visible)}>Click Me to Set Visible</Button>

<div>
Expand Down
8 changes: 8 additions & 0 deletions examples/react-component/tests/Button.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as React from 'react';
import { render, screen } from '@testing-library/react';
import Button from '../src/components/Button';

test('test <Button /> component', () => {
render(<Button>PKG</Button>);
expect(screen.getByTestId('normal-button')).toHaveTextContent('PKG');
});
8 changes: 8 additions & 0 deletions examples/react-component/tests/Index.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as React from 'react';
import { render, screen } from '@testing-library/react';
import Index from '../src/index';

test('test <Button /> component', () => {
render(<Index />);
expect(screen.getByTestId('title')).toHaveTextContent('Hello World');
});
4 changes: 4 additions & 0 deletions examples/react-component/vitest-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import matchers from '@testing-library/jest-dom/matchers';
import { expect } from 'vitest';

expect.extend(matchers);
9 changes: 9 additions & 0 deletions examples/react-component/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pkgService, { defineVitestConfig } from '@ice/pkg';

export default defineVitestConfig(pkgService, () => ({
test: {
environment: 'jsdom',
setupFiles: ['./vitest-setup.ts'],
globals: true,
},
}));
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@changesets/cli": "^2.26.0",
"@commitlint/cli": "^15.0.0",
"@iceworks/spec": "^1.6.0",
"@vitest/coverage-c8": "^0.28.5",
"eslint": "^8.19.0",
"fs-extra": "^10.1.0",
"ice-npm-utils": "workspace:^3.0.2",
Expand All @@ -38,6 +39,6 @@
"axios": "^0.23.0",
"c8": "^7.11.3",
"ts-node": "^10.8.2",
"vitest": "^0.7.13"
"vitest": "^0.28.5"
}
}
3 changes: 0 additions & 3 deletions packages/pkg/.eslintignore

This file was deleted.

4 changes: 0 additions & 4 deletions packages/pkg/.eslintrc.mjs

This file was deleted.

16 changes: 16 additions & 0 deletions packages/pkg/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 1.5.3

### Patch Changes

- f2f17ed: feat: minify css bundle
- 35bf1ca: feat: support configure jsxRuntime
- 52ccdf5: feat: support UI or unit test

## 1.5.3-beta.0

### Patch Changes

- f2f17ed: feat: minify css bundle
- 35bf1ca: feat: support configure jsxRuntime
- 52ccdf5: feat: support UI or unit test

## 1.5.2

### Patch Changes
Expand Down
11 changes: 3 additions & 8 deletions packages/pkg/bin/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@ import consola from 'consola';
import { cac } from 'cac';
import { readFileSync } from 'fs';
import { join, dirname } from 'path';
import { require } from '../lib/utils.js';
import componentService from '../lib/index.js';
import pkgService, { getBuiltInPlugins } from '../lib/index.js';

const __dirname = dirname(fileURLToPath(import.meta.url));

const getBuiltInPlugins = () => [
require.resolve('./plugins/component'),
];

const cli = cac('ice-pkg');

(async () => {
Expand All @@ -32,7 +27,7 @@ const cli = cac('ice-pkg');
delete options['--'];
const { rootDir, ...commandArgs } = options;

await componentService.run({
await pkgService.run({
command: 'build',
commandArgs,
getBuiltInPlugins,
Expand All @@ -55,7 +50,7 @@ const cli = cac('ice-pkg');
delete options['--'];
const { rootDir, ...commandArgs } = options;

await componentService.run({
await pkgService.run({
command: 'start',
commandArgs,
getBuiltInPlugins,
Expand Down
11 changes: 8 additions & 3 deletions packages/pkg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/pkg",
"version": "1.5.2",
"version": "1.5.3",
"description": "Core service of ice component",
"type": "module",
"main": "./lib/index.js",
Expand All @@ -16,7 +16,7 @@
"scripts": {
"build": "rm -rf lib && tsc",
"watch": "tsc -w",
"lint": "pnpm eslint --ext .js,.jsx,.ts,.tsx,.mts,.mjs ./",
"lint": "pnpm eslint --ext .js,.jsx,.ts,.tsx,.mts,.mjs ./src",
"prepublishOnly": "pnpm run-s lint build"
},
"author": "",
Expand Down Expand Up @@ -49,6 +49,7 @@
"fs-extra": "^10.0.0",
"globby": "^11.0.4",
"gzip-size": "^7.0.0",
"lodash.merge": "^4.6.2",
"magic-string": "^0.25.7",
"picocolors": "^1.0.0",
"postcss": "^8.4.6",
Expand All @@ -61,9 +62,13 @@
"devDependencies": {
"@types/babel__core": "^7.1.20",
"@types/fs-extra": "^9.0.13",
"@types/lodash.merge": "^4.6.7",
"@types/node": "^17.0.2",
"jest": "^29.4.3",
"cssnano": "^5.1.15",
"sass": "^1.49.8",
"source-map": "0.6.1"
"source-map": "0.6.1",
"vitest": "^0.28.5"
},
"publishConfig": {
"access": "public",
Expand Down
Loading

1 comment on commit bca916d

@vercel
Copy link

@vercel vercel bot commented on bca916d Feb 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

icepkg – ./

icepkg-git-main-icepkg.vercel.app
icepkg-icepkg.vercel.app
icepkg.vercel.app

Please sign in to comment.