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

Upgrade project dependencies; Bump node; Update yarn lockfile #80

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
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
aa5d88b
Remove npm lockfile in favor of yarn lockfile
thelovekesh May 10, 2023
6d7d05e
Remove corrupted yarn lockfile
thelovekesh May 10, 2023
b6e70d3
Remove @zeit/next-css and @zeit/next-scss packages
thelovekesh May 10, 2023
25204ff
Remove node-sass package
thelovekesh May 10, 2023
aef59f6
Remove next-offline package
thelovekesh May 10, 2023
425dd6e
Add new yarn lockfile
thelovekesh May 10, 2023
2434977
Update package.json dependencies to latest version as of 2023-05-10
thelovekesh May 10, 2023
b8f1e00
Remove unused woocommerce-api dep
thelovekesh May 10, 2023
9093719
Remove unused cookie-parser dep
thelovekesh May 10, 2023
720e404
Remove unused dotenv dep
thelovekesh May 10, 2023
88552c2
Remove unused express dep
thelovekesh May 10, 2023
c57b7bc
Remove unused graphql dep
thelovekesh May 10, 2023
a962ebb
Remove unused graphql-tag dep
thelovekesh May 10, 2023
d956946
Remove unused serialize-javascript dev-dep
thelovekesh May 10, 2023
0a4a62c
Remove unused isomorphic-unfetch dep
thelovekesh May 10, 2023
055122b
Remove unused node-fetch dep
thelovekesh May 10, 2023
00629ef
Remove unused url-loader dep
thelovekesh May 10, 2023
0fc076f
Remove unused react-bootstrap dep
thelovekesh May 10, 2023
aa73992
Remove unused next-compose-plugins dev-dep
thelovekesh May 10, 2023
8abd3d6
Add graphql
thelovekesh May 10, 2023
9fa3a30
Bump node from 14 to 18
thelovekesh May 10, 2023
505ae84
Remove main key from package.json
thelovekesh May 10, 2023
a401db7
Fix linting of package.json
thelovekesh May 10, 2023
a999bea
Update next config by removing next-offline and @zeit/{css|sass} deps
thelovekesh May 10, 2023
dc086d0
Update Link component usage by removing it\'s <a> childs
thelovekesh May 10, 2023
67f155d
Bump prettier from 2.2.1 to 2.8.8
thelovekesh May 10, 2023
4c01cea
Bump eslint-config-prettier from 7.1.0 to 8.8.0
thelovekesh May 10, 2023
234234a
Bump eslint from 7.17.0 to 8.40.0
thelovekesh May 10, 2023
8ae2f5b
Add eslint-config-next and remove other eslint configs required for n…
thelovekesh May 10, 2023
85ced31
Update eslint config and extended next/core-web-vitals config
thelovekesh May 10, 2023
1fc3477
Add .editorconfig
thelovekesh May 10, 2023
83dc41c
Update .editorconfig to use space as indent_style
thelovekesh May 10, 2023
2b3397d
Update prettier config
thelovekesh May 10, 2023
455915e
Fix eslint jsx-no-undef error
thelovekesh May 10, 2023
2a9558b
Add eslint-plugin-prettier
thelovekesh May 10, 2023
bca5d4c
Add eslint-plugin-prettier plugin
thelovekesh May 10, 2023
a34854d
Update lint and add lint:fix script
thelovekesh May 10, 2023
e78e8b4
Update formatting with prettier
thelovekesh May 10, 2023
394eed8
Add .git-blame-ignore-revs
thelovekesh May 10, 2023
e2177a7
Update npm:scripts with next cli commands
thelovekesh May 10, 2023
b51b7db
Add pages/_app.js file to include global css
thelovekesh May 10, 2023
4afb686
Add sass package
thelovekesh May 10, 2023
b0bd799
Move custom stylesheets to pages/_app.js
thelovekesh May 10, 2023
179476e
Fix exhaustive deps
thelovekesh May 10, 2023
129ed67
Add only-allow to run yarn as package manager
thelovekesh May 10, 2023
d0baf2d
Move font awesome css to pages/_document.js
thelovekesh May 10, 2023
9c5e8ec
Add script to allow deps installation with yarn package manager only
thelovekesh May 11, 2023
a615611
Remove only-allow package
thelovekesh May 11, 2023
0a129f1
Update empty occurances of conditional rendering with null
thelovekesh May 11, 2023
2de2d01
Add pre-commit hook
thelovekesh May 11, 2023
fc5175c
Add .lintstagedrc.js
thelovekesh May 11, 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
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# EditorConfig is awesome: https://EditorConfig.org

root = true

[*]
charset = utf-8
indent_size = 2
end_of_line = lf
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{js,jsx,ts,tsx}]
quote_type = single
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SITE_URL=http://localhost:3000
NEXT_PUBLIC_WOO_SITE_URL=http://yourwocommercesite.com
WOO_CONSUMER_KEY=xxxxx
WOO_SECRET=xxxxx
WOO_SECRET=xxxxx
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
**/node_modules/**
**/vendor/**
**/build/**
**/src/components/**/vendor-*
**/src/components/**/vendor-*
43 changes: 5 additions & 38 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,6 @@
module.exports = {
root: true, // Make sure eslint picks up the config at the root of the directory
parserOptions: {
ecmaVersion: 2020, // Use the latest ecmascript standard
sourceType: 'module', // Allows using import/export statements
ecmaFeatures: {
jsx: true // Enable JSX since we're using React
}
},
settings: {
react: {
version: 'detect' // Automatically detect the react version
}
},
env: {
browser: true, // Enables browser globals like window and document
amd: true, // Enables require() and define() as global variables as per the amd spec.
node: true // Enables Node.js global variables and Node.js scoping.
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended',
'plugin:prettier/recommended' // Make this the last element so prettier config overrides other formatting rules
],
rules: {
'prettier/prettier': ['error', {}, { usePrettierrc: true }], // Use our .prettierrc file as source
'react/react-in-jsx-scope': 'off',
'jsx-a11y/anchor-is-valid': [
'error',
{
components: ['Link'],
specialLink: ['hrefLeft', 'hrefRight'],
aspects: ['invalidHref', 'preferButton']
}
],
'react/prop-types': 'off'
}
const eslintConfig = {
root: true,
extends: ['next/core-web-vitals', 'plugin:prettier/recommended'],
};

module.exports = eslintConfig;
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Apply prettier formatting.
e78e8b49d22f81980b855644de7cd78c80c9673f
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ dist/
client-config.js
.next
wooConfig.js

.now
.now
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn run lint:staged
10 changes: 10 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const path = require('path');

const buildEslintCommand = (filenames) =>
`next lint --file ${filenames
.map((f) => path.relative(process.cwd(), f))
.join(' --file ')}`;

module.exports = {
'*.{js,jsx,ts,tsx}': [buildEslintCommand],
};
2 changes: 1 addition & 1 deletion .nowignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.next
.cache
.cache
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.15.0
18
8 changes: 2 additions & 6 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
node_modules
public
src/styles/vendor/
*.md
.next
.eslintrc.js
next.config.js
package-lock.json
package.json
node_modules
src/styles/vendor/
15 changes: 8 additions & 7 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"semi": true,
"tabWidth": 4,
"printWidth": 100,
"singleQuote": true,
"trailingComma": "none",
"jsxBracketSameLine": true
}
"semi": true,
"tabWidth": 2,
"printWidth": 80,
"singleQuote": true,
"bracketSpacing": true,
"trailingComma": "es5",
"bracketSameLine": false
}
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ These instructions will get you a copy of the project up and running on your loc
* [wp-graphiql](https://github.com/wp-graphql/wp-graphiql) Provides GraphiQL IDE (playground) to the WP-Admin
* [wp-graphql-woocommerce](https://github.com/wp-graphql/wp-graphql-woocommerce) Adds Woocommerce functionality to a WPGraphQL schema( Tested upto [v0.7.0](https://github.com/wp-graphql/wp-graphql-woocommerce/releases/tag/v0.7.0) of wp-graphql-woocommerce)


2. You can also import default wooCommerce products that come with wooCommerce Plugin for development ( if you don't have any products in your WordPress install )
WP Dashboard > Tools > WooCommerce products(CSV) : The WooCommerce default products csv file is available at `wp-content/plugins/woocommerce/sample-data/sample_products.csv`
WP Dashboard > Tools > WooCommerce products(CSV) : The WooCommerce default products csv file is available at `wp-content/plugins/woocommerce/sample-data/sample_products.csv`

### 2. For Authentication :lock:

a. You can use any secret token of your choice, however it would be best if you generate one using WordPress Salt generator (https://api.wordpress.org/secret-key/1.1/salt/) to generate a Secret.
And just pick up any one of the token and add it in place of 'your-secret-token' below:

Define a Secret in `wp-config.php` of your WordPress directory:
```
define( 'GRAPHQL_JWT_AUTH_SECRET_KEY', 'your-secret-token' );
```
```

b. Depending on your particular environment, you may have to research how to enable these headers, but in Apache, you can do the following in your `.htaccess`:

```
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
```
Expand Down Expand Up @@ -78,7 +78,7 @@ WOO_SECRET=xxxxx
* Open the site in Chrome on your mobile and then click on add to home screen.
* It will be downloaded and saved as a Progressive Web App on your mobile.
* Once added Look `WP Decoupled` app on your mobile.
* This PWA will work even when you are offline.
* This PWA will work even when you are offline.

## Branches Information :seedling:

Expand Down
31 changes: 31 additions & 0 deletions bin/allow-yarn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env node

const { basename, resolve } = require('path');
const { unlinkSync, existsSync } = require('fs');

if (basename(process.env.npm_execpath) !== 'yarn.js') {
console.log(`
╔═════════════════════════════════════════════════════════════╗
║ ║
║ Use "yarn" for installation in this project. ║
║ ║
║ If you don't have Yarn, install it via "npm i -g yarn". ║
║ For more details, go to https://yarnpkg.com/ ║
║ ║
╚═════════════════════════════════════════════════════════════╝
`);

try {
if (existsSync(resolve(__dirname, '../pnpm-lock.yaml'))) {
unlinkSync(resolve(__dirname, '../pnpm-lock.yaml'));
}

if (existsSync(resolve(__dirname, '../package-lock.json'))) {
unlinkSync(resolve(__dirname, '../package-lock.json'));
}
} catch (err) {
// ignore
}

process.exit(1);
}
4 changes: 2 additions & 2 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"baseUrl": "http://localhost:3000"
}
"baseUrl": "http://localhost:3000"
}
20 changes: 10 additions & 10 deletions cypress/integration/homeProduct.spec.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* eslint-disable */

describe('Visit home , if products exists, check the links by clicking', () => {
it('visit and check first product', () => {
cy.visit('http://localhost:3000');
cy.get('.products-wrapper').find('.product-container').first().click()
cy.url().should('include','/product/');
});
it('visit and check first product', () => {
cy.visit('http://localhost:3000');
cy.get('.products-wrapper').find('.product-container').first().click();
cy.url().should('include', '/product/');
});

it('visit and check last product', () => {
cy.visit('http://localhost:3000');
cy.get('.products-wrapper').find('.product-container').last().click()
cy.url().should('include','/product/');
});
it('visit and check last product', () => {
cy.visit('http://localhost:3000');
cy.get('.products-wrapper').find('.product-container').last().click();
cy.url().should('include', '/product/');
});
});
45 changes: 14 additions & 31 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,18 @@
const withCss = require('@zeit/next-css');
/**
* External dependencies
*/
const path = require('path');

const withOffline = require('next-offline');
const withSass = require('@zeit/next-sass');

const workBoxOptions = {
workboxOpts: {
swSrc: 'service-worker.js',
swDest: 'static/service-worker.js',
exclude: [/.+error\.js$/, /\.map$/]
}
const nextConfig = {
images: {
domains: [
'https://via.placeholder.com',
new URL(process.env.NEXT_PUBLIC_WOO_SITE_URL).hostname,
],
},
sassOptions: {
includePaths: [path.resolve('src', 'styles')],
},
};

const backend_hostname = new URL(process.env.NEXT_PUBLIC_WOO_SITE_URL).hostname;

module.exports = withOffline(
withCss(
withSass({
workboxOpts: workBoxOptions.workboxOpts,
generateInDevMode: true,
dontAutoRegisterSw: true,
generateSw: false,
globPatterns: ['static/**/*'],
globDirectory: '.',
target: 'serverless',
images: {
domains: [
backend_hostname,
'https://via.placeholder.com'
],
},
})
)
);
module.exports = nextConfig;
Loading