@toptal/davinci-bootstrap 3.6.2-alpha-fix-bundle-analyze-e1cf8407.5 → 3.6.2-alpha-feature-esm-migration-e551c09d.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/davinci-bootstrap.js +4 -4
- package/package.json +9 -8
- package/src/commands/new-app.js +17 -12
- package/src/commands/new-lib.js +16 -11
- package/src/commands/new.js +15 -10
- package/src/constants.js +10 -10
- package/src/index.js +4 -4
- package/src/utils/packages.js +5 -5
- package/src/utils/skeleton.js +13 -13
- package/src/utils/workspace.js +11 -8
package/bin/davinci-bootstrap.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import cliEngine from '@toptal/davinci-cli-shared'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import newCommandCreator from '../src/commands/new.js'
|
|
6
|
+
import newAppCommandCreator from '../src/commands/new-app.js'
|
|
7
|
+
import newLibCommandCreator from '../src/commands/new-lib.js'
|
|
8
8
|
|
|
9
9
|
cliEngine.loadCommands(
|
|
10
10
|
[newCommandCreator, newAppCommandCreator, newLibCommandCreator],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toptal/davinci-bootstrap",
|
|
3
|
-
"version": "3.6.2-alpha-
|
|
3
|
+
"version": "3.6.2-alpha-feature-esm-migration-e551c09d.30+e551c09d",
|
|
4
4
|
"description": "Creates application from davinci template",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"author": "Toptal",
|
|
14
14
|
"homepage": "https://github.com/toptal/davinci/tree/master/packages/bootstrap#readme",
|
|
15
15
|
"license": "ISC",
|
|
16
|
-
"
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": "./src/index.js",
|
|
17
18
|
"bin": {
|
|
18
19
|
"davinci-bootstrap": "bin/davinci-bootstrap.js"
|
|
19
20
|
},
|
|
@@ -28,21 +29,21 @@
|
|
|
28
29
|
"url": "git+https://github.com/toptal/davinci.git"
|
|
29
30
|
},
|
|
30
31
|
"scripts": {
|
|
31
|
-
"test": "
|
|
32
|
+
"test": "../../bin/unit-test.bash"
|
|
32
33
|
},
|
|
33
34
|
"bugs": {
|
|
34
35
|
"url": "https://github.com/toptal/davinci/issues"
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
37
|
-
"@toptal/davinci-cli-shared": "1.10.3-alpha-
|
|
38
|
-
"@toptal/davinci-skeleton": "10.0.1-alpha-
|
|
39
|
-
"@toptal/davinci-skeleton-lib": "0.2.1-alpha-
|
|
40
|
-
"@toptal/davinci-skeleton-sub-app": "1.3.1-alpha-
|
|
38
|
+
"@toptal/davinci-cli-shared": "1.10.3-alpha-feature-esm-migration-e551c09d.30+e551c09d",
|
|
39
|
+
"@toptal/davinci-skeleton": "10.0.1-alpha-feature-esm-migration-e551c09d.59+e551c09d",
|
|
40
|
+
"@toptal/davinci-skeleton-lib": "0.2.1-alpha-feature-esm-migration-e551c09d.262+e551c09d",
|
|
41
|
+
"@toptal/davinci-skeleton-sub-app": "1.3.1-alpha-feature-esm-migration-e551c09d.262+e551c09d",
|
|
41
42
|
"execa": "^5.1.1",
|
|
42
43
|
"find-yarn-workspace-root": "^2.0.0",
|
|
43
44
|
"fs-extra": "^9.0.1",
|
|
44
45
|
"lodash.kebabcase": "^4.1.1",
|
|
45
46
|
"ora": "^5.4.1"
|
|
46
47
|
},
|
|
47
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "e551c09d98a4e340ab16afb27a42fe52a8548d00"
|
|
48
49
|
}
|
package/src/commands/new-app.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import ora from 'ora'
|
|
4
|
+
import kebabCase from 'lodash.kebabcase'
|
|
5
|
+
import url from 'url'
|
|
6
|
+
import { print } from '@toptal/davinci-cli-shared'
|
|
7
|
+
import { createRequire } from 'module'
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
import workspace from '../utils/workspace.js'
|
|
10
|
+
import skeleton from '../utils/skeleton.js'
|
|
11
|
+
import { APPS_PATH, NAMESPACES_PATH } from '../constants.js'
|
|
12
|
+
|
|
13
|
+
const localRequire = createRequire(import.meta.url)
|
|
14
|
+
const thisScriptDirname = path.dirname(url.fileURLToPath(import.meta.url))
|
|
10
15
|
|
|
11
16
|
const getAppPath = (libName, namespace) =>
|
|
12
17
|
namespace
|
|
@@ -31,7 +36,7 @@ const checkPrerequisites = async (monorepoWorkspaceDir, appName, namespace) => {
|
|
|
31
36
|
monorepoWorkspaceDir,
|
|
32
37
|
getAppPath(appName, namespace)
|
|
33
38
|
)
|
|
34
|
-
const doesAppExist =
|
|
39
|
+
const doesAppExist = fs.existsSync(appPath)
|
|
35
40
|
|
|
36
41
|
if (doesAppExist) {
|
|
37
42
|
spinner.fail()
|
|
@@ -42,7 +47,7 @@ const checkPrerequisites = async (monorepoWorkspaceDir, appName, namespace) => {
|
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
const copyApplicationSkeleton = async (destDir, currentDavinciRunningDir) => {
|
|
45
|
-
const skeletonSubAppPath =
|
|
50
|
+
const skeletonSubAppPath = localRequire.resolve(
|
|
46
51
|
'@toptal/davinci-skeleton-sub-app',
|
|
47
52
|
{
|
|
48
53
|
paths: [currentDavinciRunningDir],
|
|
@@ -120,7 +125,7 @@ const createCommand = async (appName, namespace) => {
|
|
|
120
125
|
|
|
121
126
|
const monorepoWorkspaceDir = workspace.getRootDir()
|
|
122
127
|
const workspacePackageJson = workspace.readPackageJson(monorepoWorkspaceDir)
|
|
123
|
-
const currentDavinciRunningDir =
|
|
128
|
+
const currentDavinciRunningDir = thisScriptDirname
|
|
124
129
|
|
|
125
130
|
try {
|
|
126
131
|
// check if all apps are installed, directory doesn't exists, etc.
|
|
@@ -168,4 +173,4 @@ const newAppCommandCreator = {
|
|
|
168
173
|
},
|
|
169
174
|
}
|
|
170
175
|
|
|
171
|
-
|
|
176
|
+
export default newAppCommandCreator
|
package/src/commands/new-lib.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import ora from 'ora'
|
|
4
|
+
import url from 'url'
|
|
5
|
+
import kebabCase from 'lodash.kebabcase'
|
|
6
|
+
import { print } from '@toptal/davinci-cli-shared'
|
|
7
|
+
import { createRequire } from 'module'
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
import workspace from '../utils/workspace.js'
|
|
10
|
+
import skeleton from '../utils/skeleton.js'
|
|
11
|
+
import { LIBS_PATH, NAMESPACES_PATH } from '../constants.js'
|
|
12
|
+
|
|
13
|
+
const localRequire = createRequire(import.meta.url)
|
|
14
|
+
const thisScriptDirname = path.dirname(url.fileURLToPath(import.meta.url))
|
|
10
15
|
|
|
11
16
|
const getLibPath = (libName, namespace) =>
|
|
12
17
|
namespace
|
|
@@ -42,7 +47,7 @@ const checkPrerequisites = async (monorepoWorkspaceDir, libName, namespace) => {
|
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
const copyLibrarySkeleton = async (destDir, currentDavinciRunningDir) => {
|
|
45
|
-
const skeletonLibPath =
|
|
50
|
+
const skeletonLibPath = localRequire.resolve('@toptal/davinci-skeleton-lib', {
|
|
46
51
|
paths: [currentDavinciRunningDir],
|
|
47
52
|
})
|
|
48
53
|
const appDir = path.join(skeletonLibPath, '../..')
|
|
@@ -117,7 +122,7 @@ const createCommand = async (libName, namespace) => {
|
|
|
117
122
|
|
|
118
123
|
const monorepoWorkspaceDir = workspace.getRootDir()
|
|
119
124
|
const workspacePackageJson = workspace.readPackageJson(monorepoWorkspaceDir)
|
|
120
|
-
const currentDavinciRunningDir =
|
|
125
|
+
const currentDavinciRunningDir = thisScriptDirname
|
|
121
126
|
|
|
122
127
|
try {
|
|
123
128
|
// check if all apps are installed, directory doesn't exists, etc.
|
|
@@ -165,4 +170,4 @@ const newLibCommandCreator = {
|
|
|
165
170
|
},
|
|
166
171
|
}
|
|
167
172
|
|
|
168
|
-
|
|
173
|
+
export default newLibCommandCreator
|
package/src/commands/new.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import url from 'url'
|
|
4
|
+
import ora from 'ora'
|
|
5
|
+
import kebabCase from 'lodash.kebabcase'
|
|
6
|
+
import { print, run } from '@toptal/davinci-cli-shared'
|
|
7
|
+
import { createRequire } from 'module'
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
import skeleton from '../utils/skeleton.js'
|
|
10
|
+
import { findLatestVersionOfPackage } from '../utils/packages.js'
|
|
11
|
+
|
|
12
|
+
const localRequire = createRequire(import.meta.url)
|
|
13
|
+
const thisScriptDirname = path.dirname(url.fileURLToPath(import.meta.url))
|
|
9
14
|
|
|
10
15
|
const checkPrerequisites = async (destDir, appName) => {
|
|
11
16
|
const spinner = ora('Checking prerequisites...').start()
|
|
@@ -32,7 +37,7 @@ const checkPrerequisites = async (destDir, appName) => {
|
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
const copyApplicationSkeleton = async (destDir, currentDavinciRunningDir) => {
|
|
35
|
-
const skeletonPath =
|
|
40
|
+
const skeletonPath = localRequire.resolve('@toptal/davinci-skeleton', {
|
|
36
41
|
paths: [currentDavinciRunningDir],
|
|
37
42
|
})
|
|
38
43
|
const appDir = path.join(skeletonPath, '../..')
|
|
@@ -157,7 +162,7 @@ const createCommand = async (appName, { skipInstall }) => {
|
|
|
157
162
|
print.green('Creating', appName, '...')
|
|
158
163
|
|
|
159
164
|
const currentRunningDir = process.cwd()
|
|
160
|
-
const currentDavinciRunningDir =
|
|
165
|
+
const currentDavinciRunningDir = thisScriptDirname
|
|
161
166
|
const destDir = path.join(currentRunningDir, appName)
|
|
162
167
|
|
|
163
168
|
try {
|
|
@@ -198,4 +203,4 @@ const newCommandCreator = {
|
|
|
198
203
|
},
|
|
199
204
|
}
|
|
200
205
|
|
|
201
|
-
|
|
206
|
+
export default newCommandCreator
|
package/src/constants.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const NODE_MODULES_PATTERN = /skeleton\/node_modules/g
|
|
2
|
-
const CHANGELOG_PATTERN = /CHANGELOG.md/g
|
|
3
|
-
const DIST_PACKAGE_PATTERN = /skeleton\/dist-package/g
|
|
4
|
-
const GITHUB_SKELETON_PATTERN = /.github\/codebase-specific-workflows/g
|
|
5
|
-
const APPS_PATH = 'apps'
|
|
6
|
-
const LIBS_PATH = 'libs'
|
|
7
|
-
const NAMESPACES_PATH = 'namespaces'
|
|
8
|
-
const GITHUB_PATH = '.github'
|
|
9
|
-
const CODEBASE_SPECIFIC_WORKFLOWS_PATH = 'codebase-specific-workflows'
|
|
1
|
+
export const NODE_MODULES_PATTERN = /skeleton\/node_modules/g
|
|
2
|
+
export const CHANGELOG_PATTERN = /CHANGELOG.md/g
|
|
3
|
+
export const DIST_PACKAGE_PATTERN = /skeleton\/dist-package/g
|
|
4
|
+
export const GITHUB_SKELETON_PATTERN = /.github\/codebase-specific-workflows/g
|
|
5
|
+
export const APPS_PATH = 'apps'
|
|
6
|
+
export const LIBS_PATH = 'libs'
|
|
7
|
+
export const NAMESPACES_PATH = 'namespaces'
|
|
8
|
+
export const GITHUB_PATH = '.github'
|
|
9
|
+
export const CODEBASE_SPECIFIC_WORKFLOWS_PATH = 'codebase-specific-workflows'
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
export default {
|
|
12
12
|
NODE_MODULES_PATTERN,
|
|
13
13
|
CHANGELOG_PATTERN,
|
|
14
14
|
GITHUB_SKELETON_PATTERN,
|
package/src/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import newCommandCreator from 'commands/new.js'
|
|
2
|
+
import newAppCommandCreator from 'commands/new-app.js'
|
|
3
|
+
import newLibCommandCreator from 'commands/new-lib.js'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export default {
|
|
6
6
|
commands: [newCommandCreator, newAppCommandCreator, newLibCommandCreator],
|
|
7
7
|
newCommand: newCommandCreator,
|
|
8
8
|
newAppCommand: newAppCommandCreator,
|
package/src/utils/packages.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import execa from 'execa'
|
|
2
2
|
|
|
3
|
-
const findLatestVersionOfPackage = async (
|
|
3
|
+
export const findLatestVersionOfPackage = async (pkg, cwd) => {
|
|
4
4
|
const result = await execa(
|
|
5
5
|
'yarn',
|
|
6
|
-
['-s', '--json', 'info',
|
|
6
|
+
['-s', '--json', 'info', pkg, 'dist-tags'],
|
|
7
7
|
{ cwd }
|
|
8
8
|
)
|
|
9
9
|
|
|
@@ -13,11 +13,11 @@ const findLatestVersionOfPackage = async (package, cwd) => {
|
|
|
13
13
|
return data.latest
|
|
14
14
|
} catch (err) {
|
|
15
15
|
console.log('Error while trying to get latest version:', err)
|
|
16
|
-
console.log('package: %s, stdout: %s',
|
|
16
|
+
console.log('package: %s, stdout: %s', pkg, result.stdout)
|
|
17
17
|
throw err
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
export default {
|
|
22
22
|
findLatestVersionOfPackage,
|
|
23
23
|
}
|
package/src/utils/skeleton.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import fs from 'fs-extra'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import {
|
|
5
5
|
NODE_MODULES_PATTERN,
|
|
6
6
|
CHANGELOG_PATTERN,
|
|
7
7
|
DIST_PACKAGE_PATTERN,
|
|
8
8
|
GITHUB_SKELETON_PATTERN,
|
|
9
9
|
GITHUB_PATH,
|
|
10
10
|
CODEBASE_SPECIFIC_WORKFLOWS_PATH,
|
|
11
|
-
}
|
|
11
|
+
} from '../constants.js'
|
|
12
12
|
|
|
13
|
-
const readPackageJson = folder => {
|
|
13
|
+
export const readPackageJson = folder => {
|
|
14
14
|
const packageJsonFile = path.join(folder, 'package.json')
|
|
15
15
|
|
|
16
16
|
const configData = fs.readFileSync(packageJsonFile)
|
|
@@ -18,14 +18,14 @@ const readPackageJson = folder => {
|
|
|
18
18
|
return JSON.parse(configData)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const writePackageJson = (folder, config) => {
|
|
21
|
+
export const writePackageJson = (folder, config) => {
|
|
22
22
|
const packageJsonFile = path.join(folder, 'package.json')
|
|
23
23
|
const modifiedConfigData = JSON.stringify(config, null, 2).concat('\n')
|
|
24
24
|
|
|
25
25
|
fs.writeFileSync(packageJsonFile, modifiedConfigData)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const copyTemplatePackageJsonFile = async folder => {
|
|
28
|
+
export const copyTemplatePackageJsonFile = async folder => {
|
|
29
29
|
const packageJsonFile = path.join(folder, 'package.json')
|
|
30
30
|
const packageSkeletonJsonFile = path.join(folder, 'package.json.skeleton')
|
|
31
31
|
|
|
@@ -35,7 +35,7 @@ const copyTemplatePackageJsonFile = async folder => {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const copyTemplateGitIgnoreFile = async folder => {
|
|
38
|
+
export const copyTemplateGitIgnoreFile = async folder => {
|
|
39
39
|
const gitIgnoreFile = path.join(folder, '.gitignore')
|
|
40
40
|
const gitIgnoreSkeletonFile = path.join(folder, '.gitignore.skeleton')
|
|
41
41
|
|
|
@@ -44,7 +44,7 @@ const copyTemplateGitIgnoreFile = async folder => {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const copyTemplateEslintrc = async folder => {
|
|
47
|
+
export const copyTemplateEslintrc = async folder => {
|
|
48
48
|
const eslintrcFile = path.join(folder, '.eslintrc.js')
|
|
49
49
|
const eslintrcSkeletonFile = path.join(folder, '.eslintrc.js.skeleton')
|
|
50
50
|
|
|
@@ -53,7 +53,7 @@ const copyTemplateEslintrc = async folder => {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
const copyNpmrc = async folder => {
|
|
56
|
+
export const copyNpmrc = async folder => {
|
|
57
57
|
const npmrcFile = path.join(folder, '.npmrc')
|
|
58
58
|
const npmrcFileSkeletonFile = path.join(folder, '.npmrc.skeleton')
|
|
59
59
|
|
|
@@ -62,7 +62,7 @@ const copyNpmrc = async folder => {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
const copySPAWorkflows = async (sourceDir, destDir) => {
|
|
65
|
+
export const copySPAWorkflows = async (sourceDir, destDir) => {
|
|
66
66
|
const workflowsDir = path.join(
|
|
67
67
|
sourceDir,
|
|
68
68
|
GITHUB_PATH,
|
|
@@ -74,7 +74,7 @@ const copySPAWorkflows = async (sourceDir, destDir) => {
|
|
|
74
74
|
await fs.copy(workflowsDir, targetDir)
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
const copyAllFiles = async (sourceDir, destDir) => {
|
|
77
|
+
export const copyAllFiles = async (sourceDir, destDir) => {
|
|
78
78
|
const isSkeletonFile = src =>
|
|
79
79
|
!src.match(NODE_MODULES_PATTERN) &&
|
|
80
80
|
!src.match(DIST_PACKAGE_PATTERN) &&
|
|
@@ -84,7 +84,7 @@ const copyAllFiles = async (sourceDir, destDir) => {
|
|
|
84
84
|
await fs.copy(sourceDir, destDir, { filter: isSkeletonFile })
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
export default {
|
|
88
88
|
readPackageJson,
|
|
89
89
|
writePackageJson,
|
|
90
90
|
copyTemplatePackageJsonFile,
|
package/src/utils/workspace.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import fs from 'fs-extra'
|
|
3
|
+
import findWorkspaceRoot from 'find-yarn-workspace-root'
|
|
4
|
+
import { run } from '@toptal/davinci-cli-shared'
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
export const getRootDir = findWorkspaceRoot
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
export const getPackageName = config => config.name
|
|
9
|
+
|
|
10
|
+
export const readPackageJson = folder => {
|
|
9
11
|
const packageJsonFile = path.join(folder, 'package.json')
|
|
10
12
|
|
|
11
13
|
const configData = fs.readFileSync(packageJsonFile)
|
|
@@ -23,9 +25,10 @@ const readPackageJson = folder => {
|
|
|
23
25
|
return config
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
const installDependencies = folder =>
|
|
28
|
+
export const installDependencies = folder =>
|
|
29
|
+
run('yarn', ['install'], { cwd: folder })
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
export default {
|
|
29
32
|
getRootDir: findWorkspaceRoot,
|
|
30
33
|
readPackageJson,
|
|
31
34
|
getPackageName,
|