Skip to content

Commit aab72e7

Browse files
refactor: move into npm workspace (#1304)
* refactor: move into npm workspace * ci: move demo sites to use monorepos * fix: correct tsconfig * chore: use plugin wrapper * ci: always install using latest node * ci: don't SSR private env var * ci: configure release-please Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent eb35615 commit aab72e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+694
-343
lines changed

.github/workflows/release-please.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,27 @@ jobs:
1616
id: release
1717
with:
1818
token: ${{ steps.get-token.outputs.token }}
19-
release-type: node
20-
package-name: '@netlify/plugin-nextjs'
19+
command: manifest
2120
- uses: actions/checkout@v2
22-
if: ${{ steps.release.outputs.release_created }}
21+
if: ${{ steps.release.outputs.releases_created }}
2322
- uses: actions/setup-node@v2
2423
with:
2524
node-version: '*'
2625
cache: 'npm'
2726
check-latest: true
2827
registry-url: 'https://registry.npmjs.org'
29-
if: ${{ steps.release.outputs.release_created }}
28+
if: ${{ steps.release.outputs.releases_created }}
3029
- name: Install dependencies
3130
run: npm ci
32-
if: ${{ steps.release.outputs.release_created }}
31+
working-directory: plugin
32+
if: ${{ steps.release.outputs.releases_created }}
3333
- run: npm publish
34-
if: ${{ steps.release.outputs.release_created }}
34+
working-directory: plugin
35+
if: ${{ steps.release.outputs.releases_created }}
3536
env:
3637
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
3738
- uses: netlify/submit-build-plugin-action@v1
38-
if: ${{ steps.release.outputs.release_created }}
39+
if: ${{ steps.release.outputs.releases_created }}
3940
with:
4041
github-token: ${{ steps.get-token.outputs.token }}
42+
package-json-dir: plugin

.github/workflows/test.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,20 @@ jobs:
2525

2626
steps:
2727
- uses: actions/checkout@v2
28-
- name: Use Node.js ${{ matrix.node-version }}
28+
- name: Installing with latest Node.js
2929
uses: actions/setup-node@v2
30+
if: "${{ matrix.node-version != '*' }}"
3031
with:
31-
node-version: ${{ matrix.node-version }}
32+
node-version: '*'
3233
check-latest: true
3334
- name: NPM Install
3435
run: npm ci
36+
- name: Switching to Node.js ${{ matrix.node-version }} to run tests
37+
uses: actions/setup-node@v2
38+
if: "${{ matrix.node-version != '*' }}"
39+
with:
40+
node-version: ${{ matrix.node-version }}
41+
check-latest: true
3542
- name: Linting
3643
run: npm run format:ci
3744
if: "${{ matrix.node-version == '*' }}"
@@ -55,14 +62,21 @@ jobs:
5562
if: github.ref_name == 'main'
5663
steps:
5764
- uses: actions/checkout@v2
58-
- name: Use Node.js ${{ matrix.node-version }}
65+
- name: Installing with latest Node.js
5966
uses: actions/setup-node@v2
67+
if: "${{ matrix.node-version != '*' }}"
6068
with:
61-
node-version: ${{ matrix.node-version }}
69+
node-version: '*'
6270
check-latest: true
6371
- name: NPM Install
6472
run: npm ci
6573
- name: Install Next.js Canary
6674
run: npm install -D next@canary --legacy-peer-deps
75+
- name: Switching to Node.js ${{ matrix.node-version }} to run tests
76+
uses: actions/setup-node@v2
77+
if: "${{ matrix.node-version != '*' }}"
78+
with:
79+
node-version: ${{ matrix.node-version }}
80+
check-latest: true
6781
- name: Run tests against next@canary
6882
run: npm test

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
17.9.0

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ logs
33
*.log
44
npm-debug.log*
55

6+
package.json
7+
68
# Dependency directories
79
node_modules
810

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"plugin": "4.3.2"
3+
}

demos/base-path/netlify.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ CYPRESS_CACHE_FOLDER = "../node_modules/.CypressBinary"
1212
framework = "#static"
1313

1414
[[plugins]]
15-
package = "./local-plugin"
15+
package = "../plugin-wrapper/"
1616

1717
[[plugins]]
1818
package = "@netlify/plugin-local-install-core"
19-
2019
# [[context.deploy-preview.plugins]]
21-
# package = "netlify-plugin-cypress"
20+
# package = "netlify-plugin-cypress"

demos/base-path/package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "base-path-demo",
3+
"version": "1.0.0",
4+
"description": "",
5+
"devDependencies": {
6+
"@netlify/plugin-nextjs": "*"
7+
},
8+
"scripts": {
9+
"test": "echo \"Error: no test specified\" && exit 1"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/netlify/netlify-plugin-nextjs.git"
14+
},
15+
"author": "",
16+
"private": true,
17+
"license": "MIT",
18+
"bugs": {
19+
"url": "https://github.com/netlify/netlify-plugin-nextjs/issues"
20+
},
21+
"homepage": "https://github.com/netlify/netlify-plugin-nextjs#readme"
22+
}

demos/default/local-plugin/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

demos/default/local-plugin/manifest.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

demos/default/local-plugin/package.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

demos/default/netlify.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
[build]
22
command = "next build"
33
publish = ".next"
4-
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ../../"
4+
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../../plugin"
55

66
[build.environment]
77
# cache Cypress binary in local "node_modules" folder
88
# so Netlify caches it
99
CYPRESS_CACHE_FOLDER = "../node_modules/.CypressBinary"
1010
# set TERM variable for terminal output
1111
TERM = "xterm"
12+
NODE_VERSION = "17"
1213

1314
[dev]
1415
framework = "#static"
1516

1617
[[plugins]]
17-
package = "./local-plugin"
18+
package = "../plugin-wrapper/"
1819

20+
# This is a fake plugin, that makes it run npm install
1921
[[plugins]]
20-
package = "@netlify/plugin-local-install-core"
22+
package = "@netlify/plugin-local-install-core"

demos/default/package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "default-demo",
3+
"version": "1.0.0",
4+
"private": true,
5+
"description": "",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/netlify/netlify-plugin-nextjs.git"
12+
},
13+
"author": "",
14+
"license": "MIT",
15+
"bugs": {
16+
"url": "https://github.com/netlify/netlify-plugin-nextjs/issues"
17+
},
18+
"homepage": "https://github.com/netlify/netlify-plugin-nextjs#readme",
19+
"dependencies": {
20+
"@reach/dialog": "^0.16.2",
21+
"@reach/visually-hidden": "^0.16.0"
22+
},
23+
"devDependencies": {
24+
"@netlify/plugin-nextjs": "*"
25+
}
26+
}

demos/default/pages/env.tsx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,39 @@
1+
import { useEffect, useState } from 'react'
2+
13
/**
24
* https://nextjs.org/docs/basic-features/environment-variables
35
*/
46
function EnvTest() {
7+
const [showEnv, setShowEnv] = useState(false)
8+
useEffect(() => setShowEnv(true), [])
59
return (
610
<div>
711
<h1>Environment Variables</h1>
812
<a href="https://nextjs.org/docs/basic-features/environment-variables">Read Docs</a>
9-
<p>By default environment variables are only available in the Node.js environment, meaning they won&apos;t be exposed to the browser.</p>
1013
<p>
11-
<code>NEXT_PUBLIC_</code> environment variables are available in the browser, and can be used to configure the application.
14+
By default environment variables are only available in the Node.js environment, meaning they won&apos;t be
15+
exposed to the browser.
16+
</p>
17+
<p>
18+
<code>NEXT_PUBLIC_</code> environment variables are available in the browser, and can be used to configure the
19+
application.
1220
</p>
13-
<p>✅ Public Environment token found: <code>{process.env.NEXT_PUBLIC_GREETINGS || 'NOT FOUND (something went wrong)'}</code></p>
14-
<p>❌ Private Environment token should not be found: <code>{process.env.TEST_ENV_VAR || 'Everything worked'}</code></p>
21+
{showEnv ? (
22+
<>
23+
<p>
24+
✅ Public Environment token found:{' '}
25+
<code>{process.env.NEXT_PUBLIC_GREETINGS || 'NOT FOUND (something went wrong)'}</code>
26+
</p>
27+
<p>
28+
❌ Private Environment token should not be found:{' '}
29+
<code>{process.env.TEST_ENV_VAR || 'Everything worked'}</code>
30+
</p>
31+
</>
32+
) : (
33+
'We only want to test client-side env vars'
34+
)}
1535
</div>
1636
)
1737
}
1838

19-
export default EnvTest
39+
export default EnvTest

demos/default/tsconfig.json

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
{
2+
"extends": "../../tsconfig.json",
23
"compilerOptions": {
3-
"target": "es5",
44
"lib": [
5-
"dom",
6-
"dom.iterable",
7-
"esnext"
5+
"es2019",
6+
"dom"
87
],
9-
"allowJs": true,
10-
"skipLibCheck": true,
118
"strict": false,
12-
"forceConsistentCasingInFileNames": true,
139
"noEmit": true,
14-
"esModuleInterop": true,
15-
"module": "esnext",
10+
"incremental": true,
1611
"moduleResolution": "node",
1712
"resolveJsonModule": true,
1813
"isolatedModules": true,
19-
"jsx": "preserve",
20-
"incremental": true
14+
"jsx": "preserve"
2115
},
2216
"include": [
2317
"next-env.d.ts",
@@ -27,4 +21,4 @@
2721
"exclude": [
2822
"node_modules"
2923
]
30-
}
24+
}

demos/next-export/local-plugin/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

demos/next-export/local-plugin/manifest.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

demos/next-export/local-plugin/package-lock.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

demos/next-export/local-plugin/package.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

demos/next-export/netlify.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ../../"
55

66
[build.environment]
77
NETLIFY_NEXT_PLUGIN_SKIP = "true"
8+
NODE_VERSION = "17"
89

910
[dev]
1011
framework = "#static"
1112

1213
[[plugins]]
13-
package = "./local-plugin"
14+
package = "../plugin-wrapper/"
1415

1516
[[plugins]]
1617
package = "@netlify/plugin-local-install-core"

demos/next-export/package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "next-export-demo",
3+
"version": "1.0.0",
4+
"description": "",
5+
"devDependencies": {
6+
"@netlify/plugin-nextjs": "*"
7+
},
8+
"scripts": {
9+
"test": "echo \"Error: no test specified\" && exit 1"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/netlify/netlify-plugin-nextjs.git"
14+
},
15+
"author": "",
16+
"private": true,
17+
"license": "MIT",
18+
"bugs": {
19+
"url": "https://github.com/netlify/netlify-plugin-nextjs/issues"
20+
},
21+
"homepage": "https://github.com/netlify/netlify-plugin-nextjs#readme"
22+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require('../../../lib')
1+
module.exports = require('../../../plugin/lib')

demos/plugin-wrapper/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// eslint-disable-next-line node/no-unpublished-require
2+
module.exports = require('../../plugin/lib')

demos/plugin-wrapper/manifest.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
name: 'plugin-wrapper'

demos/plugin-wrapper/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "local-plugin",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"author": "",
6+
"license": "MIT",
7+
"scripts": {
8+
"test": "echo \"Error: no test specified\" && exit 1"
9+
},
10+
"devDependencies": {
11+
"@netlify/plugin-nextjs": "*",
12+
"husky": "^7.0.4",
13+
"npm-run-all": "^4.1.5"
14+
}
15+
}

demos/static-root/netlify.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ../../"
77
# cache Cypress binary in local "node_modules" folder
88
# so Netlify caches it
99
CYPRESS_CACHE_FOLDER = "../node_modules/.CypressBinary"
10+
NODE_VERSION = "17"
1011

1112
[dev]
1213
framework = "#static"
1314

1415
[[plugins]]
15-
package = "./local-plugin"
16+
package = "../plugin-wrapper/"
1617

1718
[[plugins]]
1819
package = "@netlify/plugin-local-install-core"
19-
20-
[[context.deploy-preview.plugins]]
21-
package = "netlify-plugin-cypress"

0 commit comments

Comments
 (0)