Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize build dependencies #177

Merged
merged 51 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
6501c89
Vite migration beginning
medied Nov 9, 2023
bb520b7
Move index.html
medied Nov 9, 2023
38408ee
build.lib
medied Nov 10, 2023
d6e27d1
use module script
hueitan Nov 13, 2023
af00292
Update index.html
medied Nov 13, 2023
895a5ae
Move index.html
medied Nov 14, 2023
7ef24b2
Add define config
medied Nov 14, 2023
e1c3350
temp comment out for CI pass
hueitan Nov 15, 2023
12e7d84
temp for demo build script
hueitan Nov 15, 2023
7e5dac0
temp
hueitan Nov 15, 2023
3cd6471
temp build script
hueitan Nov 15, 2023
f1e0aa2
enable storybook but not all
hueitan Nov 15, 2023
3aa50ab
enable storybook but not all yet
hueitan Nov 15, 2023
8ce5ae1
wikipedia-preview.css
medied Nov 15, 2023
3ce454a
Remove inline-svg
medied Nov 15, 2023
749c9f8
Include link.css in main entry point
medied Nov 15, 2023
2ae9324
Remove webpack config
medied Nov 15, 2023
ad11cf8
Update vite config imports
medied Nov 15, 2023
161fcf6
replace wba with vba
hueitan Nov 15, 2023
56395e9
bring back the storybook
hueitan Nov 17, 2023
93d6f52
replace mocha using vite
hueitan Nov 17, 2023
afa9297
replace assert using vitest expect
hueitan Nov 17, 2023
89006ec
enable unit test
hueitan Nov 17, 2023
4d874cc
update dependencies
hueitan Nov 17, 2023
52b5159
Update CI (#178)
xuanxu Nov 17, 2023
664cec1
Ignore coverage
medied Nov 17, 2023
99e01e9
Update dependencies
medied Nov 17, 2023
fe9dabe
npm uninstall eslint-loader
medied Nov 20, 2023
ff60f1d
Update eslint to work with Vite
medied Nov 20, 2023
7d9ad80
add eslint fix
hueitan Nov 20, 2023
adc9d1c
update npm run dev script
hueitan Nov 20, 2023
4e5fd59
update docs
hueitan Nov 20, 2023
b9c4636
remove it, this run within dev script
hueitan Nov 20, 2023
9831370
fix eslint ci err
hueitan Nov 20, 2023
b88c56d
revert link styling doc
hueitan Nov 20, 2023
63c7745
cypress migration
hueitan Nov 20, 2023
4b72969
enable cypress in CI
hueitan Nov 20, 2023
eb9510e
use latest version of node in CI
hueitan Nov 21, 2023
c0bcc62
Fix translation issue
medied Nov 21, 2023
b9d62c6
Linting
medied Nov 21, 2023
0e1ab4f
specific engines
hueitan Nov 22, 2023
bca07ce
Remove commented out code
medied Nov 27, 2023
e15a69e
code split set to true
hueitan Nov 28, 2023
f8d5131
Revert "code split set to true"
hueitan Nov 28, 2023
258d40d
Revert "Revert "code split set to true""
hueitan Nov 28, 2023
e72689a
Move link.css to demo directory
medied Nov 29, 2023
c4e53c7
update demo.sh script
hueitan Nov 30, 2023
5664576
add node 17 to ci test
hueitan Dec 5, 2023
413b671
Update main.yml
hueitan Dec 5, 2023
197c123
Remove unicorn
medied Dec 5, 2023
5cae0c7
Add postbuild and update README
medied Dec 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ module.exports = {
browser: true,
es6: true
},
extends: [
'eslint:recommended',
'wikimedia/client',
'plugin:cypress/recommended'
],
extends: ['eslint:recommended', 'wikimedia/client', 'plugin:cypress/recommended', 'plugin:storybook/recommended'],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
Expand All @@ -18,11 +14,15 @@ module.exports = {
ecmaVersion: 2018,
sourceType: 'module'
},
ignorePatterns: ["storybook-static", "dist", "vite.config.js"],
rules: {
semi: [2, 'never'],
'no-nonoctal-decimal-escape': 'off',
'no-only-tests/no-only-tests': 'error',
'cypress/no-unnecessary-waiting': 'warn'
'cypress/no-unnecessary-waiting': 'warn',
'es-x/no-rest-spread-properties': 'off',
'es-x/no-export-ns-from': 'off',
'es-x/no-regexp-named-capture-groups': 'off'
},
plugins: [
'cypress',
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ on:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
strategy:
matrix:
node: [ 17, 'latest' ]

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: '16'
node-version: ${{ matrix.node }}

- name: Install and Build
run: |
Expand All @@ -39,17 +42,17 @@ jobs:

- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v5
uses: tj-actions/branch-names@v7

- name: Deploy Pages 🚀
uses: JamesIves/github-pages-deploy-action@4.1.5
uses: JamesIves/github-pages-deploy-action@v4.4.3
with:
branch: gh-pages
folder: demo
target-folder: ${{ steps.branch-name.outputs.current_branch }}

- name: Deploy Storybook 🚀
uses: JamesIves/github-pages-deploy-action@4.1.5
uses: JamesIves/github-pages-deploy-action@v4.4.3
with:
branch: gh-pages
folder: storybook-static
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/
.nyc_output/
.DS_Store
storybook-static
coverage/
26 changes: 9 additions & 17 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
const webpack = require('webpack')
const path = require('path');

const custom = require('../webpack.config.js')(null, {mode: 'development'});

module.exports = {
"stories": [
"../src/**/*.stories.js"
],

"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials"
],
webpackFinal: (config) => {
return {
...config,
plugins: [
...config.plugins,
new webpack.DefinePlugin( {
APP_VERSION: '"(mock app version)"',
GIT_HASH: '"(mock git hash)"'
} ) ],
module: {
...config.module,
rules: custom.module.rules
}
};

framework: {
name: "@storybook/html-vite",
options: {}
},

docs: {
autodocs: false
}
}
6 changes: 3 additions & 3 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"extends": "stylelint-config-wikimedia",
"plugins": ["stylelint-no-unsupported-browser-features"],
"plugins": [ "stylelint-no-unsupported-browser-features" ],
"rules": {
"plugin/no-unsupported-browser-features": [true, {
"plugin/no-unsupported-browser-features": [ true, {
"severity": "warning",
"ignorePartialSupport": true
}],
} ],
"declaration-property-unit-disallowed-list": false
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ To use the default trigger link styling:

* Add the following link to the page header:
```html
<link href="wikipedia-preview.css" rel="stylesheet">
<link href="wikipedia-preview-link.css" rel="stylesheet">
```
* Add the class `wmf-wp-with-preview` to the node

If you prefer to style them in a way that makes more sense for your context, simply don't include the `wikipediaPreview.css` link in the header and add your own class to the node. Both of these are valid ways:
If you prefer to style them in a way that makes more sense for your context, simply don't include the `wikipedia-preview-link.css` link in the header and add your own class to the node. Both of these are valid ways:

```CSS
[data-wikipedia-preview] {
Expand Down
9 changes: 9 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from 'cypress'

export default defineConfig( {
defaultCommandTimeout: 8000,
chromeWebSecurity: false,
e2e: {
baseUrl: 'http://localhost:5173/' // your localhost port in vite (5173 is the default for vite server)
}
} )
5 changes: 0 additions & 5 deletions cypress.json

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe( 'Check the Gallery Pages ', () => {
// Open the Preview
preview.getPreviewSpan().first().click()
// Check for the Continue Reading exist
preview.getFooterContinueReading().then( res => {
preview.getFooterContinueReading().then( ( res ) => {
if ( res.css( 'display' ) !== 'none' ) {
preview.getFooterContinueReading().click()
}
Expand All @@ -35,7 +35,7 @@ describe( 'Check the Gallery Pages ', () => {
// Open the Preview
preview.getPreviewSpan().first().click()
// Check for the Continue Reading exist
preview.getFooterContinueReading().then( res => {
preview.getFooterContinueReading().then( ( res ) => {
if ( res.css( 'display' ) !== 'none' ) {
preview.getFooterContinueReading().click()
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe( 'Check the Gallery Pages in Mobile View', () => {
// Open the Preview
preview.getPreviewSpan().first().click()
// Check for the Continue Reading exist
preview.getFooterContinueReading().then( res => {
preview.getFooterContinueReading().then( ( res ) => {
if ( res.css( 'display' ) !== 'none' ) {
preview.getFooterContinueReading().click()
}
Expand All @@ -41,7 +41,7 @@ describe( 'Check the Gallery Pages in Mobile View', () => {
// Open the Preview
preview.getPreviewSpan().first().click()
// Check for the Continue Reading exist
preview.getFooterContinueReading().then( res => {
preview.getFooterContinueReading().then( ( res ) => {
if ( res.css( 'display' ) !== 'none' ) {
preview.getFooterContinueReading().click()
}
Expand All @@ -64,7 +64,7 @@ describe( 'Check the Gallery Pages in Mobile View', () => {
// Open the Preview
preview.getPreviewSpan().eq( 4 ).click()
// Check for the Continue Reading exist
preview.getFooterContinueReading().then( res => {
preview.getFooterContinueReading().then( ( res ) => {
if ( res.css( 'display' ) !== 'none' ) {
preview.getFooterContinueReading().click()
}
Expand All @@ -77,7 +77,7 @@ describe( 'Check the Gallery Pages in Mobile View', () => {
// Check the Gallery Page
gallery.checkGalleryPage( i )
// Check if the Caption Bar exist
gallery.getGalleryCaptionBar( i ).its( 'length' ).then( len => {
gallery.getGalleryCaptionBar( i ).its( 'length' ).then( ( len ) => {
if ( len > 0 ) {
// Scroll the Caption Text
gallery.getGalleryCaptionBar( i ).click()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe( 'Check the Gallery Pages in Mobile View', () => {
// Open the Preview
preview.getPreviewSpan().eq( 4 ).click()
// Check for the Continue Reading exist
preview.getFooterContinueReading().then( res => {
preview.getFooterContinueReading().then( ( res ) => {
if ( res.css( 'display' ) !== 'none' ) {
preview.getFooterContinueReading().click()
}
Expand All @@ -35,7 +35,7 @@ describe( 'Check the Gallery Pages in Mobile View', () => {
// Open the Preview
preview.getPreviewSpan().eq( 4 ).click()
// Check for the Continue Reading exist
preview.getFooterContinueReading().then( res => {
preview.getFooterContinueReading().then( ( res ) => {
if ( res.css( 'display' ) !== 'none' ) {
preview.getFooterContinueReading().click()
}
Expand All @@ -48,7 +48,7 @@ describe( 'Check the Gallery Pages in Mobile View', () => {
// Check the Gallery Page
gallery.checkGalleryPage( i )
// Check if the Caption Bar exist
gallery.getGalleryCaptionBar( i ).its( 'length' ).then( len => {
gallery.getGalleryCaptionBar( i ).its( 'length' ).then( ( len ) => {
if ( len > 0 ) {
// Scroll the Caption Text
// gallery.getGalleryCaption( i ).swipe( 'bottom', 'center' )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
preview.getPreviewSpan().eq( 0 ).click()

// Continue Reading is available
preview.getFooterContinueReading().then( res => {
preview.getFooterContinueReading().then( ( res ) => {
if ( res.css( 'display' ) !== 'none' ) {
preview.getFooterContinueReading().click()
}
} )

// Open the Wikipedia Page in the same window
preview.getFooterReadMore().should( $a => {
preview.getFooterReadMore().should( ( $a ) => {
expect( $a.attr( 'target' ), 'target' ).to.equal( '_blank' )
$a.attr( 'target', '_self' )
} ).click()
Expand All @@ -33,7 +33,7 @@

// Check for the Preview
preview.getPreviewSpan().eq( 0 ).click()
cy.wait( 1000 )

Check warning on line 36 in cypress/e2e/page-movement.cy.js

View workflow job for this annotation

GitHub Actions / build (17)

Do not wait for arbitrary time periods

Check warning on line 36 in cypress/e2e/page-movement.cy.js

View workflow job for this annotation

GitHub Actions / build (latest)

Do not wait for arbitrary time periods
preview.checkPreview()
preview.getHeaderClosebtn().click()

Expand All @@ -49,7 +49,7 @@

// Check for the Preview
preview.getPreviewSpan().eq( 0 ).click()
cy.wait( 1000 )

Check warning on line 52 in cypress/e2e/page-movement.cy.js

View workflow job for this annotation

GitHub Actions / build (17)

Do not wait for arbitrary time periods

Check warning on line 52 in cypress/e2e/page-movement.cy.js

View workflow job for this annotation

GitHub Actions / build (latest)

Do not wait for arbitrary time periods
preview.checkPreview()
preview.getHeaderClosebtn().click()

Expand Down
16 changes: 8 additions & 8 deletions cypress/page-objects/preview-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class Preview {
this.getHeader().should( 'be.visible' )
this.getHeaderWatermark().should( 'be.visible' )
this.getHeaderClosebtn().should( 'be.visible' )
this.getHeaderImage().its( 'length' ).then( len => {
this.getHeaderImage().its( 'length' ).then( ( len ) => {
if ( len > 0 ) {
this.getHeaderImage().should( 'be.visible' )
}
Expand All @@ -121,7 +121,7 @@ export class Preview {
this.getBody().should( 'be.visible' )
this.getBodyContent().should( 'be.visible' )
.and( 'have.css', 'font-size' ).and( 'equal', '18px' )
this.getHeaderImage().its( 'length' ).then( len => {
this.getHeaderImage().its( 'length' ).then( ( len ) => {
if ( len > 0 ) {
this.getBodyGallery().scrollIntoView().should( 'be.visible' )
this.getBodyGalleryImages().should( 'be.visible' )
Expand All @@ -140,15 +140,15 @@ export class Preview {
this.getHeaderWatermark().should( 'be.visible' )
this.getHeaderClosebtn().should( 'be.visible' )

this.getPreview().then( tag => {
this.getPreview().then( ( tag ) => {

const lang = tag.attr( 'lang' )

this.getBody().should( 'be.visible' )
.and( 'have.class', 'wikipediapreview-body-disambiguation' )
.and( 'have.css', 'font-size' ).and( 'equal', '16px' )

this.getBodyMessage().then( ele => {
this.getBodyMessage().then( ( ele ) => {
cy.wrap( ele ).find( 'div.wikipediapreview-body-icon' )
} )

Expand All @@ -166,15 +166,15 @@ export class Preview {
this.getHeaderWatermark().should( 'be.visible' )
this.getHeaderClosebtn().should( 'be.visible' )

this.getPreview().then( tag => {
this.getPreview().then( ( tag ) => {

const lang = tag.attr( 'lang' )

this.getBody().should( 'be.visible' )
.and( 'have.class', 'wikipediapreview-body-offline' )
.and( 'have.css', 'font-size' ).and( 'equal', '16px' )

this.getBodyMessage().then( ele => {
this.getBodyMessage().then( ( ele ) => {
cy.wrap( ele ).find( 'div.wikipediapreview-body-icon' ).should( 'be.visible' )
cy.wrap( ele ).find( 'span' ).should( 'contain', msg( lang, 'preview-offline-message' ) )

Expand All @@ -194,15 +194,15 @@ export class Preview {
this.getHeaderWatermark().should( 'be.visible' )
this.getHeaderClosebtn().should( 'be.visible' )

this.getPreview().then( tag => {
this.getPreview().then( ( tag ) => {

const lang = tag.attr( 'lang' )

this.getBody().should( 'be.visible' )
.and( 'have.class', 'wikipediapreview-body-error' )
.and( 'have.css', 'font-size' ).and( 'equal', '16px' )

this.getBodyMessage().then( ele => {
this.getBodyMessage().then( ( ele ) => {
cy.wrap( ele ).find( 'div.wikipediapreview-body-icon' )
cy.wrap( ele ).find( 'span' ).should( 'contain', msg( lang, 'preview-error-message' ) )

Expand Down
2 changes: 1 addition & 1 deletion cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @type {Cypress.PluginConfig}
*/
// eslint-disable-next-line no-unused-vars
module.exports = ( on, config ) => {
export default ( on, config ) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
6 changes: 3 additions & 3 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Cypress.Commands.add( 'navigateToTestPage', () => {
cy.visit( '/articles/test.html' )
cy.visit( 'demo/articles/test.html' )
} )

Cypress.Commands.add( 'navigateToEnglishPage', () => {
cy.visit( '/articles/english.html' )
cy.visit( 'demo/articles/english.html' )
} )

Cypress.Commands.add( 'navigateToMobileTestPage', () => {
cy.viewport( 550, 750 )
cy.visitMobile( '/articles/test.html' )
cy.visitMobile( 'demo/articles/test.html' )
} )
File renamed without changes.
4 changes: 2 additions & 2 deletions demo/articles/arabic.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<link href="../css/header.css" rel="stylesheet" type="text/css"/>
<link href="../css/footer.css" rel="stylesheet" type="text/css"/>
<link href="../css/article.css" rel="stylesheet" type="text/css"/>
<link href="../wikipedia-preview.css" rel="stylesheet" type="text/css"/>
<link href="../css/link.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<a href="../index.html">
Expand Down Expand Up @@ -52,7 +52,7 @@
</p>
</div>
<!-- Scripts -->
<script src="../wikipedia-preview.development.js"></script>
hueitan marked this conversation as resolved.
Show resolved Hide resolved
<script src="/dist/wikipedia-preview.umd.cjs"></script>
hueitan marked this conversation as resolved.
Show resolved Hide resolved
<script>
wikipediaPreview.init({
lang: 'ar'
Expand Down
4 changes: 2 additions & 2 deletions demo/articles/bahasaIndonesia.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<link href="../css/header.css" rel="stylesheet" type="text/css"/>
<link href="../css/footer.css" rel="stylesheet" type="text/css"/>
<link href="../css/article.css" rel="stylesheet" type="text/css"/>
<link href="../wikipedia-preview.css" rel="stylesheet" type="text/css"/>
<link href="../css/link.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<a href="../index.html">
Expand Down Expand Up @@ -49,7 +49,7 @@
</p>
</div>
<!-- Scripts -->
<script src="../wikipedia-preview.development.js"></script>
<script src="/dist/wikipedia-preview.umd.cjs"></script>
<script>
wikipediaPreview.init({
lang: 'id',
Expand Down
Loading