Skip to content

Commit

Permalink
[angular-ngrx-scss]: update Angular to 16 & Storybook to 7 (#1322)
Browse files Browse the repository at this point in the history
* chore: ng update to angular 14

* chore: update ngrx to v14

* chore: ng update angular and ngrx to 15

* chore: update storybook

* chore: ng update to angular and ngrx v16

* chore: update storybook to 7.2 and run prettier

* fix: fix build storybook script

* fix: pin dependencies
  • Loading branch information
honzikec authored Aug 4, 2023
1 parent f079203 commit dd9d5dc
Show file tree
Hide file tree
Showing 17 changed files with 160 additions and 166 deletions.
10 changes: 5 additions & 5 deletions starters/angular-ngrx-scss/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ module.exports = {
env: {
browser: true,
node: true,
es2021: true
es2021: true,
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:storybook/recommended'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'eslint-plugin-html', 'unused-imports'],
rules: {
'unused-imports/no-unused-imports-ts': 1
}
};
'unused-imports/no-unused-imports-ts': 1,
},
};
32 changes: 20 additions & 12 deletions starters/angular-ngrx-scss/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import { dirname, join } from 'path';
module.exports = {
"stories": [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
getAbsolutePath('@storybook/addon-links'),
getAbsolutePath('@storybook/addon-essentials'),
getAbsolutePath('@storybook/addon-interactions'),
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions"
],
"framework": "@storybook/angular",
"core": {
"builder": "@storybook/builder-webpack5"
}
framework: {
name: getAbsolutePath('@storybook/angular'),
options: {},
},
docs: {
autodocs: true,
},
};
/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value) {
return dirname(require.resolve(join(value, 'package.json')));
}
10 changes: 5 additions & 5 deletions starters/angular-ngrx-scss/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { setCompodocJson } from "@storybook/addon-docs/angular";
import docJson from "../documentation.json";
import { setCompodocJson } from '@storybook/addon-docs/angular';
import docJson from '../documentation.json';
setCompodocJson(docJson);

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
docs: { inlineStories: true },
}
docs: { story: { inline: true } },
};
19 changes: 4 additions & 15 deletions starters/angular-ngrx-scss/.storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
{
"extends": "../tsconfig.app.json",
"compilerOptions": {
"types": [
"node"
],
"types": ["node"],
"allowSyntheticDefaultImports": true
},
"exclude": [
"../src/test.ts",
"../src/**/*.spec.ts",
"../projects/**/*.spec.ts"
],
"include": [
"../src/**/*",
"../projects/**/*"
],
"files": [
"./typings.d.ts"
]
"exclude": ["../src/test.ts", "../src/**/*.spec.ts", "../projects/**/*.spec.ts"],
"include": ["../src/**/*", "../projects/**/*"],
"files": ["./typings.d.ts"]
}
3 changes: 1 addition & 2 deletions starters/angular-ngrx-scss/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"pathMapping": {
"/_karma_webpack_": "${workspaceFolder}"
}
},

}
]
}
7 changes: 3 additions & 4 deletions starters/angular-ngrx-scss/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": 1,
"cli": {
"analytics": false,
"defaultCollection": "@ngrx/schematics",
"packageManager": "yarn"
"packageManager": "yarn",
"schematicCollections": ["@ngrx/schematics"]
},
"newProjectRoot": "projects",
"projects": {
Expand Down Expand Up @@ -115,6 +115,5 @@
}
}
}
},
"defaultProject": "angular-ngrx-scss"
}
}
12 changes: 6 additions & 6 deletions starters/angular-ngrx-scss/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ module.exports = function (config) {
browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: "ChromeHeadless",
base: 'ChromeHeadless',
flags: [
"--no-sandbox",
"--user-data-dir=/tmp/chrome-test-profile",
"--disable-web-security",
"--remote-debugging-address=0.0.0.0",
"--remote-debugging-port=9222",
'--no-sandbox',
'--user-data-dir=/tmp/chrome-test-profile',
'--disable-web-security',
'--remote-debugging-address=0.0.0.0',
'--remote-debugging-port=9222',
],
debug: true,
},
Expand Down
61 changes: 31 additions & 30 deletions starters/angular-ngrx-scss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,52 +32,51 @@
"test": "ng test",
"test:ci": "ng test --browsers=ChromeHeadless --no-watch",
"docs:json": "compodoc -p ./tsconfig.json -e json -d .",
"storybook": "yarn docs:json && start-storybook -p 6006",
"build-storybook": "yarn docs:json && build-storybook",
"storybook": "yarn docs:json && ng run angular-ngrx-scss:storybook",
"build-storybook": "yarn docs:json && ng run angular-ngrx-scss:build-storybook",
"dev": "yarn start",
"lint": "eslint .",
"prettier": "prettier -w ."
},
"dependencies": {
"@angular/animations": "13.3.12",
"@angular/common": "13.3.12",
"@angular/compiler": "13.3.12",
"@angular/core": "13.3.12",
"@angular/forms": "13.3.12",
"@angular/platform-browser": "13.3.12",
"@angular/platform-browser-dynamic": "13.3.12",
"@angular/router": "13.3.12",
"@ngrx/effects": "13.2.0",
"@ngrx/store": "13.2.0",
"@ngrx/store-devtools": "13.2.0",
"@angular/animations": "16.1.7",
"@angular/common": "16.1.7",
"@angular/compiler": "16.1.7",
"@angular/core": "16.1.7",
"@angular/forms": "16.1.7",
"@angular/platform-browser": "16.1.7",
"@angular/platform-browser-dynamic": "16.1.7",
"@angular/router": "16.1.7",
"@ngrx/effects": "16.1.0",
"@ngrx/store": "16.1.0",
"@ngrx/store-devtools": "16.1.0",
"rxjs": "7.8.0",
"tslib": "2.5.0",
"zone.js": "0.11.4"
"zone.js": "0.13.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "13.3.10",
"@angular/cli": "13.3.10",
"@angular/compiler-cli": "13.3.12",
"@angular-devkit/build-angular": "16.1.6",
"@angular/cli": "16.1.6",
"@angular/compiler-cli": "16.1.7",
"@babel/core": "7.20.12",
"@compodoc/compodoc": "1.1.19",
"@eslint/create-config": "0.4.2",
"@ngrx/schematics": "13.2.0",
"@storybook/addon-actions": "6.5.16",
"@storybook/addon-essentials": "6.5.16",
"@storybook/addon-interactions": "6.5.16",
"@storybook/addon-links": "6.5.16",
"@storybook/angular": "6.5.16",
"@storybook/builder-webpack5": "6.5.16",
"@storybook/manager-webpack5": "6.5.16",
"@storybook/testing-library": "0.0.13",
"@ngrx/schematics": "16.1.0",
"@storybook/addon-actions": "7.2.0",
"@storybook/addon-essentials": "7.2.0",
"@storybook/addon-interactions": "7.2.0",
"@storybook/addon-links": "7.2.0",
"@storybook/angular": "7.2.0",
"@storybook/builder-vite": "7.2.0",
"@storybook/testing-library": "0.2.0",
"@types/jasmine": "3.10.7",
"@types/node": "12.20.55",
"@types/node": "20.4.5",
"@typescript-eslint/eslint-plugin": "5.51.0",
"@typescript-eslint/parser": "5.51.0",
"babel-loader": "8.3.0",
"eslint": "8.33.0",
"eslint-plugin-html": "6.2.0",
"eslint-plugin-storybook": "0.6.10",
"eslint-plugin-storybook": "0.6.13",
"eslint-plugin-unused-imports": "2.0.0",
"jasmine-core": "3.99.1",
"karma": "6.4.1",
Expand All @@ -86,7 +85,9 @@
"karma-jasmine": "4.0.2",
"karma-jasmine-html-reporter": "1.7.0",
"prettier": "2.8.4",
"sb": "6.5.16",
"typescript": "4.6.2"
"react": "18.2.0",
"react-dom": "18.2.0",
"storybook": "7.2.0",
"typescript": "4.9.5"
}
}
9 changes: 8 additions & 1 deletion starters/angular-ngrx-scss/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ import { environment } from '../environments/environment';
import { metaReducers, reducers } from './state/reducers';

@NgModule({
declarations: [AppComponent, StarterButtonComponent, CounterExampleComponent, FetchExampleComponent, LoaderComponent, HomeComponent],
declarations: [
AppComponent,
StarterButtonComponent,
CounterExampleComponent,
FetchExampleComponent,
LoaderComponent,
HomeComponent,
],
imports: [
BrowserModule,
AppRoutingModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// also exported from '@storybook/angular' if you can deal with breaking changes in 6.1
import { APP_BASE_HREF } from '@angular/common';
import { AppRoutingModule } from '../app-routing.module';
import { BrowserModule } from '@angular/platform-browser';
import { CounterExampleComponent } from './counter-example.component';
import { StarterButtonComponent } from './starter-button/starter-button.component';
import type { Meta, StoryObj } from '@storybook/angular';

import { applicationConfig, moduleMetadata } from '@storybook/angular';
import { importProvidersFrom } from '@angular/core';
import { StoreModule } from '@ngrx/store';
import { Story, Meta } from '@storybook/angular/types-6-0';
import { moduleMetadata } from '@storybook/angular';
import { reducers, metaReducers } from '../state/reducers';

// More on default export: https://storybook.js.org/docs/angular/writing-stories/introduction#default-export
export default {
const meta: Meta<CounterExampleComponent> = {
title: 'Example/Counter Example Page',
component: CounterExampleComponent,
// More on argTypes: https://storybook.js.org/docs/angular/api/argtypes
Expand All @@ -24,21 +24,20 @@ export default {
},
],
declarations: [StarterButtonComponent],
imports: [BrowserModule, AppRoutingModule, StoreModule.forRoot(reducers, { metaReducers })],
}),
applicationConfig({
providers: [importProvidersFrom(StoreModule.forRoot(reducers, { metaReducers }))],
}),
],
parameters: {
controls: {
exclude: ['count$'],
},
},
} as Meta;
};

export default meta;

// More on component templates: https://storybook.js.org/docs/angular/writing-stories/introduction#using-args
const Template: Story<CounterExampleComponent> = (args: CounterExampleComponent) => ({
props: args,
});
type Story = StoryObj<CounterExampleComponent>;

export const Page = Template.bind({});
// More on args: https://storybook.js.org/docs/angular/writing-stories/args
Page.args = {};
export const Page: Story = { args: {} };
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
// also exported from '@storybook/angular' if you can deal with breaking changes in 6.1
import { Story, Meta } from '@storybook/angular/types-6-0';
import { StarterButtonComponent } from './starter-button.component';

import type { Meta, StoryObj } from '@storybook/angular';

// More on default export: https://storybook.js.org/docs/angular/writing-stories/introduction#default-export
export default {
const meta: Meta<StarterButtonComponent> = {
title: 'Example/Button',
component: StarterButtonComponent,
// More on argTypes: https://storybook.js.org/docs/angular/api/argtypes
argTypes: {
backgroundColor: { control: 'color' },
},
} as Meta;
};
export default meta;

// More on component templates: https://storybook.js.org/docs/angular/writing-stories/introduction#using-args
const Template: Story<StarterButtonComponent> = (args: StarterButtonComponent) => ({
props: args,
});
type Story = StoryObj<StarterButtonComponent>;

export const Primary = Template.bind({});
// More on args: https://storybook.js.org/docs/angular/writing-stories/args
Primary.args = {
primary: true,
label: 'Button',
export const Primary: Story = {
args: {
primary: true,
label: 'Button',
},
};

export const Secondary = Template.bind({});
Secondary.args = {
label: 'Button',
export const Secondary: Story = {
args: {
label: 'Button',
},
};

export const Large = Template.bind({});
Large.args = {
size: 'large',
label: 'Button',
export const Large: Story = {
args: {
size: 'large',
label: 'Button',
},
};

export const Small = Template.bind({});
Small.args = {
size: 'small',
label: 'Button',
export const Small: Story = {
args: {
size: 'small',
label: 'Button',
},
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.fetch-example{
.fetch-example {
width: 40%;
&__greeting {
text-align: center;
Expand Down
Loading

0 comments on commit dd9d5dc

Please sign in to comment.