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

feat(gatsby-dev-cli): add verdaccio support #11525

Merged
merged 83 commits into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
4e587ba
feat(gatsby-dev-cli): add verdaccio support [wip]
pieh Feb 3, 2019
3e2d0d5
yuck - don't look
pieh Feb 3, 2019
e5c179c
just to verify verdaccio
pieh Feb 3, 2019
641a91c
fix gitignore and add htpasswd with dummy gatsby-dev user
pieh Feb 3, 2019
6f555ab
some logging to understand why it tries to handle all the packages
pieh Feb 3, 2019
41d9583
just temporarily so it hopefully at least works
pieh Feb 3, 2019
c69e1f7
moar data
pieh Feb 3, 2019
571a8ae
don't copy all the packages right now
pieh Feb 3, 2019
408aeca
don't rely on package name starting with "gatsby" heuristic
pieh Feb 3, 2019
d1ec15b
tmp commit
pieh Feb 4, 2019
af89ec5
tmp
pieh Feb 4, 2019
4de0f3a
fs change
pieh Feb 4, 2019
d51ac61
Merge remote-tracking branch 'origin/master' into dev-verdaccio
pieh Mar 20, 2019
be2e6c1
tmp
pieh Mar 20, 2019
eca2644
a
pieh Mar 20, 2019
229f02c
updates
pieh Mar 21, 2019
f9edc11
remove random files that shouldn't be here
pieh Mar 21, 2019
9018f6d
tmp
pieh Mar 21, 2019
071bc16
revert dep changes
pieh Mar 21, 2019
7fb7c74
ignore changes to package.json created during publishing
pieh Mar 22, 2019
e1287a7
testing of dep change in gatsby-cli is picked up by gatsby-dev-cli
pieh Mar 22, 2019
09a2441
let's see if gatsby-dev will handle case of no node_modules
pieh Mar 22, 2019
9f51113
sanity check
pieh Mar 22, 2019
29f63a6
adjust console message
pieh Mar 22, 2019
87d426c
add missing devDeps
pieh Mar 22, 2019
4071a24
more missing devDeps
pieh Mar 22, 2019
6ab2a24
grab package.json from unpkg if package is not yet installed locally
pieh Mar 22, 2019
e70a1e0
Merge remote-tracking branch 'origin/master' into dev-verdaccio
pieh Mar 22, 2019
c044394
correctly ignore package.json changes during publishing
pieh Mar 22, 2019
a679496
cleaning things up
pieh Mar 22, 2019
35748c6
htpasswd loc
pieh Mar 22, 2019
1b27f5a
restore gatsby package.json
pieh Mar 22, 2019
d354d5b
adjust ignore files
pieh Mar 22, 2019
634c406
gatsby-dev-cli: ignore tests
pieh Mar 22, 2019
0706879
Merge remote-tracking branch 'origin/master' into dev-verdaccio
pieh Mar 22, 2019
45838c2
remove extra ln
pieh Mar 22, 2019
685213c
less console output
pieh Mar 22, 2019
bc4bdc1
turns out you don't need htpasswd after all
pieh Mar 22, 2019
2d948d3
use exact when installing local packages - timestamp is used in version
pieh Mar 22, 2019
734e51e
why it failed?
pieh Mar 22, 2019
e534677
use yarn for publishing - see https://github.com/verdaccio/verdaccio/…
pieh Mar 22, 2019
7b56ebf
v0.1.1
pieh Mar 22, 2019
bf4d5eb
add temporary .npmrc file to allow anonymous publishes
pieh Mar 22, 2019
42c9b78
add some jsdocs
pieh Mar 22, 2019
5ea67a9
update yarn.lock
pieh Mar 22, 2019
dcdaf02
oops
pieh Mar 22, 2019
fc1045a
debug why still can't publish anon
pieh Mar 23, 2019
302ea47
adjust npmrc content
pieh Mar 23, 2019
0b7a7b0
doh
pieh Mar 23, 2019
42acc31
Revert "debug why still can't publish anon"
pieh Mar 23, 2019
5364ccf
Merge remote-tracking branch 'origin/master' into dev-verdaccio
pieh Mar 25, 2019
61679d1
handle package installation of deps didn't change
pieh Mar 25, 2019
1b3193b
Merge remote-tracking branch 'origin/master' into dev-verdaccio
pieh Mar 26, 2019
04c59c5
skip version changes for packages in gatsby mono-repo, queue copying …
pieh Mar 26, 2019
ba221b7
fix tests
pieh Mar 26, 2019
85a27ee
packages stored in verdaccio storage seems to be picked up by jest an…
pieh Mar 27, 2019
a145185
bye "wat", you will be missed
pieh Mar 27, 2019
99ae4b8
bail early to avoid conditional bracket hell
pieh Mar 27, 2019
a9b5aa9
more bailing early
pieh Mar 27, 2019
3270d94
more concise
pieh Mar 27, 2019
33fff32
new line
pieh Mar 27, 2019
af0a0ae
use exaca to simplify running yarn
pieh Mar 27, 2019
c04bd7e
clean up www/.gitignore
pieh Mar 27, 2019
ab28b27
Merge remote-tracking branch 'origin/master' into dev-verdaccio
pieh Mar 27, 2019
5e0373b
handle not existing packages
pieh Mar 28, 2019
48890c0
remove unused (was needed for basic auth)
pieh Mar 28, 2019
cc8faca
cleanup temp file changes when process exit in middle of publishing
pieh Mar 28, 2019
e33a383
Apply suggestions from code review
wardpeet Mar 28, 2019
09c1ae7
ops
pieh Mar 28, 2019
0d148dc
cleanup unpkg response handler
pieh Mar 28, 2019
7a37d5d
move stuff around
pieh Mar 28, 2019
0d0895f
remove tmp comment
pieh Mar 28, 2019
bbce98b
document traversePackageDocs fn
pieh Mar 28, 2019
7e66caf
restrcuture files
pieh Mar 28, 2019
a962399
add basic tests for traversingPackageDeps
pieh Mar 28, 2019
5002629
add basic tests for generating packages to publish (based on dep graph)
pieh Mar 28, 2019
c8578cd
fix tests on windows
pieh Mar 29, 2019
64c7870
Merge remote-tracking branch 'upstream/master' into dev-verdaccio
pieh Mar 29, 2019
cde13fb
handle circular dependencies when constructing list of packages to pu…
pieh Mar 29, 2019
3960fa9
Merge remote-tracking branch 'origin/master' into dev-verdaccio
pieh Apr 2, 2019
65e040e
remove cat ;(
pieh Apr 2, 2019
14ea6c8
restore original e2e-test script
pieh Apr 2, 2019
d11552a
update gitignore
pieh Apr 2, 2019
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
7 changes: 6 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ const builtTestsDirs = pkgs
.filter(p => fs.existsSync(path.join(p, `src`)))
.map(p => path.join(p, `__tests__`))
const distDirs = pkgs.map(p => path.join(p, `dist`))
const ignoreDirs = [].concat(gatsbyBuildDirs, builtTestsDirs, distDirs)
const ignoreDirs = [`<rootDir>/packages/gatsby-dev-cli/verdaccio`].concat(
gatsbyBuildDirs,
builtTestsDirs,
distDirs
)

const coverageDirs = pkgs.map(p => path.join(p, `src/**/*.js`))
const useCoverage = !!process.env.GENERATE_JEST_REPORT

Expand Down
3 changes: 2 additions & 1 deletion packages/babel-plugin-remove-graphql-queries/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"babel-preset-gatsby-package": "^0.1.4"
"babel-preset-gatsby-package": "^0.1.4",
"cross-env": "^5.1.4"
},
"license": "MIT",
"main": "index.js",
Expand Down
4 changes: 3 additions & 1 deletion packages/babel-preset-gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"watch": "babel -w src --out-dir . --ignore **/__tests__"
},
"devDependencies": {
"babel-preset-gatsby-package": "^0.1.4"
"@babel/cli": "^7.0.0",
"babel-preset-gatsby-package": "^0.1.4",
"cross-env": "^5.1.4"
}
}
3 changes: 3 additions & 0 deletions packages/gatsby-dev-cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ node_modules

decls
dist

# verdaccio local storage
verdaccio
1 change: 1 addition & 0 deletions packages/gatsby-dev-cli/.npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
src
flow-typed
verdaccio
8 changes: 6 additions & 2 deletions packages/gatsby-dev-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@
"@babel/runtime": "^7.0.0",
"chokidar": "^1.7.0",
"configstore": "^3.1.0",
"execa": "^1.0.0",
"fs-extra": "^4.0.1",
"is-absolute": "^0.2.6",
"lodash": "^4.17.10",
"request": "2.88.0",
"signal-exit": "^3.0.2",
"verdaccio": "^3.11.1",
"yargs": "^8.0.2"
},
"devDependencies": {
Expand All @@ -32,9 +36,9 @@
"main": "index.js",
"repository": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-dev-cli",
"scripts": {
"build": "babel src --out-dir dist",
"build": "babel src --out-dir dist --ignore **/__tests__",
"prepare": "cross-env NODE_ENV=production npm run build",
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "babel -w src --out-dir dist"
"watch": "babel -w src --out-dir dist --ignore **/__tests__"
}
}
24 changes: 18 additions & 6 deletions packages/gatsby-dev-cli/src/__tests__/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,21 @@ describe(`watching`, () => {
expect(fs.copy).not.toHaveBeenCalled()
})

it(`copies files on watch event`, () => {
it(`it doesn't copy files before ready event`, async () => {
const filePath = path.join(process.cwd(), `packages/gatsby/dist/index.js`)
watch(...args)
callEventCallback(`add`, filePath)
await callEventCallback(`add`, filePath)

expect(fs.copy).toHaveBeenCalledTimes(0)
})

it(`copies files after ready event`, async () => {
const filePath = path.join(process.cwd(), `packages/gatsby/dist/index.js`)
watch(...args)
await callEventCallback(`add`, filePath)
await callReadyCallback()

// console.log(`checking`)

expect(fs.copy).toHaveBeenCalledTimes(1)
expect(fs.copy).toHaveBeenCalledWith(
Expand All @@ -72,14 +83,15 @@ describe(`watching`, () => {
)
})

it(`copies cache-dir files`, () => {
it(`copies cache-dir files`, async () => {
watch(...args)

const filePath = path.join(
process.cwd(),
`packages/gatsby/cache-dir/register-service-worker.js`
)
callEventCallback(`add`, filePath)
await callEventCallback(`add`, filePath)
await callReadyCallback()

expect(fs.copy).toHaveBeenCalledTimes(2)
expect(fs.copy).toHaveBeenLastCalledWith(
Expand Down Expand Up @@ -122,9 +134,9 @@ describe(`watching`, () => {
global.process = realProcess
})

it(`does not exit if scanOnce is not defined`, () => {
it(`does not exit if scanOnce is not defined`, async () => {
watch(...args)
callReadyCallback()
await callReadyCallback()

expect(process.exit).not.toHaveBeenCalled()
})
Expand Down
14 changes: 7 additions & 7 deletions packages/gatsby-dev-cli/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,14 @@ let packages = Object.keys(
_.merge({}, localPkg.dependencies, localPkg.devDependencies)
)

// get list of packages from monorepo
const monoRepoPackages = fs.readdirSync(path.join(gatsbyLocation, `packages`))

if (argv.copyAll) {
packages = fs.readdirSync(path.join(gatsbyLocation, `packages`))
packages = monoRepoPackages
} else {
const { dependencies } = JSON.parse(
fs.readFileSync(path.join(gatsbyLocation, `packages/gatsby/package.json`))
)
packages = packages
.concat(Object.keys(dependencies))
.filter(p => p.startsWith(`gatsby`))
// intersect dependencies with monoRepoPackags to get list of packages to watch
packages = _.intersection(monoRepoPackages, packages)
wardpeet marked this conversation as resolved.
Show resolved Hide resolved
}

if (!argv.packages && _.isEmpty(packages)) {
Expand All @@ -104,4 +103,5 @@ gatsby-dev will pick them up.
watch(gatsbyLocation, argv.packages || packages, {
quiet: argv.quiet,
scanOnce: argv.scanOnce,
monoRepoPackages,
})
19 changes: 19 additions & 0 deletions packages/gatsby-dev-cli/src/local-npm-registry/cleanup-tasks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const signalExit = require(`signal-exit`)

const cleanupTasks = new Set()

exports.registerCleanupTask = taskFn => {
cleanupTasks.add(taskFn)
return () => {
const result = taskFn()
cleanupTasks.delete(taskFn)
return result
}
}

signalExit(() => {
if (cleanupTasks.size) {
console.log(`Process exitted in middle of publishing - cleaning up`)
cleanupTasks.forEach(taskFn => taskFn())
}
})
Loading