Skip to content

Commit 2a011dc

Browse files
Kristoffer J. Sivertsenbjoerge
Kristoffer J. Sivertsen
authored andcommitted
[vision] Move vision into monorepo (#90)
1 parent 1fa017e commit 2a011dc

Some content is hidden

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

45 files changed

+2936
-134
lines changed

gulpfile.js

+20-9
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,40 @@ const through = require('through2')
1010
const chalk = require('chalk')
1111
const childProcess = require('child_process')
1212

13-
const scripts = './packages/@sanity/*/src/**/*.js'
14-
const assets = './packages/@sanity/*/src/**/*'
13+
const scripts = ['./packages/@sanity/*/src/**/*.js', './packages/sanity-plugin-*/src/**/*.js']
14+
const assets = ['./packages/@sanity/*/src/**/*', './packages/sanity-plugin-*/src/**/*']
15+
const srcOpts = {base: 'packages'}
1516

1617
let srcEx
18+
let srcRootEx
1719
let libFragment
1820

1921
if (path.win32 === path) {
2022
srcEx = /(@sanity\\[^\\]+)\\src\\/
23+
srcRootEx = /(sanity-plugin-[^\\]+)\\src\\/
2124
libFragment = '$1\\lib\\'
2225
} else {
2326
srcEx = new RegExp('(@sanity/[^/]+)/src/')
27+
srcRootEx = /(sanity-plugin-[^/]+)\/src\//
2428
libFragment = '$1/lib/'
2529
}
2630

27-
const mapToDest = orgPath => orgPath.replace(srcEx, libFragment)
28-
const dest = 'packages/@sanity'
31+
const mapToDest = orgPath => {
32+
const outPath = orgPath
33+
.replace(srcEx, libFragment)
34+
.replace(srcRootEx, libFragment)
35+
36+
return outPath
37+
}
38+
39+
const dest = 'packages'
2940

3041
gulp.task('default', ['build'])
3142

3243
gulp.task('build', () => {
3344
const assetFilter = filter(['**/*.js'], {restore: true})
3445

35-
return gulp.src(assets)
46+
return gulp.src(assets, srcOpts)
3647
.pipe(plumber({errorHandler: err => gutil.log(err.stack)}))
3748
.pipe(newer({map: mapToDest}))
3849
.pipe(assetFilter)
@@ -51,11 +62,11 @@ gulp.task('build', () => {
5162
})
5263

5364
gulp.task('watch-js', () => {
54-
return gulp.src(scripts)
65+
return gulp.src(scripts, srcOpts)
5566
.pipe(plumber({errorHandler: err => gutil.log(err.stack)}))
5667
.pipe(through.obj((file, enc, callback) => {
5768
file._path = file.path
58-
file.path = file.path.replace(srcEx, libFragment)
69+
file.path = mapToDest(file.path)
5970
callback(null, file)
6071
}))
6172
.pipe(newer(dest))
@@ -68,12 +79,12 @@ gulp.task('watch-js', () => {
6879
})
6980

7081
gulp.task('watch-assets', () => {
71-
return gulp.src(assets)
82+
return gulp.src(assets, srcOpts)
7283
.pipe(filter(['**/*.*', '!**/*.js']))
7384
.pipe(plumber({errorHandler: err => gutil.log(err.stack)}))
7485
.pipe(through.obj((file, enc, callback) => {
7586
file._path = file.path
76-
file.path = file.path.replace(srcEx, libFragment)
87+
file.path = mapToDest(file.path)
7788
callback(null, file)
7889
}))
7990
.pipe(newer(dest))

lerna.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"packages": [
55
"packages/@sanity/*",
66
"packages/example-studio",
7+
"packages/sanity-plugin-vision",
78
"packages/storybook"
89
],
910
"version": "0.108.13"

0 commit comments

Comments
 (0)