@salesforce/lds-core-release 1.415.0 → 1.416.1
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/package.json +1 -1
- package/src/release.py +63 -5
package/package.json
CHANGED
package/src/release.py
CHANGED
|
@@ -13,6 +13,9 @@ script_path = Path(__file__).resolve()
|
|
|
13
13
|
script_directory = script_path.parent
|
|
14
14
|
assets_path = script_directory / 'assets'
|
|
15
15
|
|
|
16
|
+
MODULE_PREFIXES = ["lds", "luvio"]
|
|
17
|
+
GENERATED_HEADER_MARKER = "THIS IS A GENERATED FILE FROM https://github.com/salesforce-experience-platform-emu/lds-lightning-platform"
|
|
18
|
+
|
|
16
19
|
async def usingPerforce(coreDir):
|
|
17
20
|
isPerforceDir = True
|
|
18
21
|
try:
|
|
@@ -130,6 +133,53 @@ def requires_js_meta(file: Path):
|
|
|
130
133
|
else:
|
|
131
134
|
return False
|
|
132
135
|
|
|
136
|
+
def resolve_artifact_sfdc_root(output_dir: Path):
|
|
137
|
+
candidates = [
|
|
138
|
+
output_dir / 'sfdc',
|
|
139
|
+
output_dir if output_dir.name == 'sfdc' else None,
|
|
140
|
+
output_dir / 'lds' / 'sfdc',
|
|
141
|
+
]
|
|
142
|
+
for candidate in candidates:
|
|
143
|
+
if candidate and candidate.exists():
|
|
144
|
+
return candidate
|
|
145
|
+
raise SystemExit(
|
|
146
|
+
"LDS release artifact directory does not contain 'sfdc'. "
|
|
147
|
+
"Provide the path that contains the 'sfdc' folder (or the 'sfdc' folder itself)."
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
def module_has_generated_header(module_dir: Path, module_name: str):
|
|
151
|
+
module_js_path = module_dir / f"{module_name}.js"
|
|
152
|
+
if not module_js_path.exists():
|
|
153
|
+
return False
|
|
154
|
+
try:
|
|
155
|
+
return GENERATED_HEADER_MARKER in module_js_path.read_text()
|
|
156
|
+
except Exception:
|
|
157
|
+
return False
|
|
158
|
+
|
|
159
|
+
def list_module_names(module_root: Path, prefixes: List[str] = None, require_generated_header: bool = False):
|
|
160
|
+
if not module_root.exists():
|
|
161
|
+
print(f"Module root does not exist: {module_root}")
|
|
162
|
+
return set()
|
|
163
|
+
|
|
164
|
+
module_names = set()
|
|
165
|
+
for entry in module_root.iterdir():
|
|
166
|
+
if not entry.is_dir():
|
|
167
|
+
continue
|
|
168
|
+
if prefixes and not any(entry.name.startswith(prefix) for prefix in prefixes):
|
|
169
|
+
continue
|
|
170
|
+
if require_generated_header and not module_has_generated_header(entry, entry.name):
|
|
171
|
+
continue
|
|
172
|
+
module_names.add(entry.name)
|
|
173
|
+
return module_names
|
|
174
|
+
|
|
175
|
+
def detect_deleted_modules(artifact_sfdc_root: Path, core_dir: Path, prefixes: List[str]):
|
|
176
|
+
artifact_module_root = artifact_sfdc_root / 'ui-force-components' / 'modules' / 'force'
|
|
177
|
+
core_module_root = core_dir / 'ui-force-components' / 'modules' / 'force'
|
|
178
|
+
|
|
179
|
+
artifact_modules = list_module_names(artifact_module_root, require_generated_header=True)
|
|
180
|
+
core_modules = list_module_names(core_module_root, prefixes, require_generated_header=True)
|
|
181
|
+
return sorted(core_modules - artifact_modules)
|
|
182
|
+
|
|
133
183
|
def replace_string_in_file(file_path: Path, old_string: str, new_string: str, success_string: str ="String replaced successfully!"):
|
|
134
184
|
try:
|
|
135
185
|
# Read the contents of the file
|
|
@@ -171,21 +221,29 @@ async def main():
|
|
|
171
221
|
parser = argparse.ArgumentParser(description="The release script for LDS")
|
|
172
222
|
parser.add_argument("-o", "--outputDir", help="Path to the output directory generated by yarn build:core-artifacts")
|
|
173
223
|
parser.add_argument("-c", "--coreDir", help="Path to the target core directory")
|
|
224
|
+
parser.add_argument("--report-deleted", action="store_true", help="Report modules present in core but missing from the release artifact")
|
|
174
225
|
args, unknown = parser.parse_known_args()
|
|
175
226
|
|
|
176
227
|
source_filepath = Path(args.outputDir or input("Enter the location of the LDS release artifact. Default: ./output: ") or './output').expanduser()
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
raise SystemExit(f"LDS release artifact directory({source_filepath}) does not seem to exist. Did you provide the correct path? Did you run yarn build:core-artifacts?")
|
|
228
|
+
artifact_sfdc_root = resolve_artifact_sfdc_root(source_filepath)
|
|
229
|
+
print("LDS Release artifact path:", artifact_sfdc_root)
|
|
180
230
|
destination_filepath = Path(args.coreDir or input("Enter the core filepath. Default: /opt/workspace/core-public/core: ") or '/opt/workspace/core-public/core').expanduser()
|
|
181
231
|
print("Destination filepath:", destination_filepath)
|
|
182
232
|
if not (destination_filepath / 'ui-force-components').exists():
|
|
183
233
|
raise SystemExit(f"Destination core directory does not seem to contain ui-force-components. Did you provide the correct path to your core directory?")
|
|
184
234
|
# Print the entered filepaths
|
|
235
|
+
if args.report_deleted:
|
|
236
|
+
deleted_modules = detect_deleted_modules(artifact_sfdc_root, destination_filepath, MODULE_PREFIXES)
|
|
237
|
+
if deleted_modules:
|
|
238
|
+
print(f"Deleted modules detected ({len(deleted_modules)}):")
|
|
239
|
+
for module in deleted_modules:
|
|
240
|
+
print(f" - {module}")
|
|
241
|
+
else:
|
|
242
|
+
print("No deleted modules detected")
|
|
243
|
+
return
|
|
185
244
|
|
|
186
|
-
|
|
187
245
|
useP4 = await usingPerforce(destination_filepath)
|
|
188
|
-
new_modules = await copy_release(
|
|
246
|
+
new_modules = await copy_release(artifact_sfdc_root, destination_filepath, useP4)
|
|
189
247
|
|
|
190
248
|
if(len(new_modules) == 0):
|
|
191
249
|
print(f"No new modules detected")
|