tailjng 0.1.15 → 0.1.16
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/cli/file-operations.js +3 -13
- package/cli/settings/path-utils.js +20 -4
- package/package.json +1 -1
package/cli/file-operations.js
CHANGED
|
@@ -86,7 +86,8 @@ function findTailjngPackageRoot() {
|
|
|
86
86
|
|
|
87
87
|
async function copySharedFolderIfNeeded(componentPath, isDependency = false, options = {}) {
|
|
88
88
|
const { forceSync = false } = options
|
|
89
|
-
const
|
|
89
|
+
const packageRoot = findTailjngPackageRoot()
|
|
90
|
+
const sharedInfo = getSharedFolderInfo(componentPath, packageRoot)
|
|
90
91
|
if (!sharedInfo) {
|
|
91
92
|
return true
|
|
92
93
|
}
|
|
@@ -95,15 +96,7 @@ async function copySharedFolderIfNeeded(componentPath, isDependency = false, opt
|
|
|
95
96
|
return true
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
const packageRoot = findTailjngPackageRoot()
|
|
99
99
|
const sharedSrc = path.join(packageRoot, ...sharedInfo.sourceRelative.split("/"))
|
|
100
|
-
if (!fs.existsSync(sharedSrc)) {
|
|
101
|
-
console.error(
|
|
102
|
-
`${COLORS.red}${COLORS.bright}[tailjng CLI]${COLORS.reset} ${COLORS.red}ERROR: Shared utilities ${COLORS.bright}"${sharedInfo.groupKey}/shared"${COLORS.reset} ${COLORS.red}not found in package.${COLORS.reset}`,
|
|
103
|
-
)
|
|
104
|
-
console.error(`${COLORS.dim} Expected: ${sharedSrc}${COLORS.reset}`)
|
|
105
|
-
return false
|
|
106
|
-
}
|
|
107
100
|
|
|
108
101
|
const projectRoot = process.cwd()
|
|
109
102
|
const sharedDest = buildSharedFolderTargetPath(projectRoot, componentPath)
|
|
@@ -189,10 +182,7 @@ async function copyComponentFiles(componentName, componentPath, isDependency = f
|
|
|
189
182
|
|
|
190
183
|
fs.mkdirSync(targetPath, { recursive: true })
|
|
191
184
|
copyDirectoryRecursive(nodeModulesPath, targetPath, projectRoot)
|
|
192
|
-
|
|
193
|
-
if (!sharedOk) {
|
|
194
|
-
process.exit(1)
|
|
195
|
-
}
|
|
185
|
+
await copySharedFolderIfNeeded(componentPath, isDependency, { forceSync: true })
|
|
196
186
|
|
|
197
187
|
return true
|
|
198
188
|
}
|
|
@@ -59,14 +59,22 @@ function isComponentInstalled(projectRoot, componentName, componentPath) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* When a registry path is nested (e.g. toggle-radio/toggle-radio), returns sibling `shared/` info
|
|
63
|
-
*
|
|
62
|
+
* When a registry path is nested (e.g. toggle-radio/toggle-radio), returns sibling `shared/` info
|
|
63
|
+
* only if that group actually ships a `shared/` folder in the package (e.g. toggle-radio).
|
|
64
|
+
* Nested paths like `.config/colors` or `select/select-dropdown` have no group shared folder.
|
|
65
|
+
*
|
|
66
|
+
* @param {string} componentPath
|
|
67
|
+
* @param {string | null} [packageRoot] When set, returns null unless shared exists in the package.
|
|
64
68
|
*/
|
|
65
|
-
function getSharedFolderInfo(componentPath) {
|
|
69
|
+
function getSharedFolderInfo(componentPath, packageRoot = null) {
|
|
66
70
|
if (!componentPath.startsWith(COMPONENTS_SOURCE_PREFIX)) {
|
|
67
71
|
return null
|
|
68
72
|
}
|
|
69
73
|
|
|
74
|
+
if (isConfigPath(componentPath)) {
|
|
75
|
+
return null
|
|
76
|
+
}
|
|
77
|
+
|
|
70
78
|
const relativePath = componentPath.slice(COMPONENTS_SOURCE_PREFIX.length)
|
|
71
79
|
const pathParts = relativePath.split("/")
|
|
72
80
|
if (pathParts.length < 2) {
|
|
@@ -74,10 +82,18 @@ function getSharedFolderInfo(componentPath) {
|
|
|
74
82
|
}
|
|
75
83
|
|
|
76
84
|
const groupKey = pathParts.slice(0, -1).join("/")
|
|
85
|
+
const sourceRelative = `${COMPONENTS_SOURCE_PREFIX}${groupKey}/shared`
|
|
86
|
+
|
|
87
|
+
if (packageRoot) {
|
|
88
|
+
const sharedSrc = path.join(packageRoot, ...sourceRelative.split("/"))
|
|
89
|
+
if (!fs.existsSync(sharedSrc)) {
|
|
90
|
+
return null
|
|
91
|
+
}
|
|
92
|
+
}
|
|
77
93
|
|
|
78
94
|
return {
|
|
79
95
|
groupKey,
|
|
80
|
-
sourceRelative
|
|
96
|
+
sourceRelative,
|
|
81
97
|
targetRelative: `${groupKey}/shared`,
|
|
82
98
|
}
|
|
83
99
|
}
|