@alephium/web3 0.31.1 → 0.31.2
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.
|
@@ -221,6 +221,22 @@ class ProjectArtifact {
|
|
|
221
221
|
}
|
|
222
222
|
exports.ProjectArtifact = ProjectArtifact;
|
|
223
223
|
ProjectArtifact.artifactFileName = '.project.json';
|
|
224
|
+
function removeOldArtifacts(dir) {
|
|
225
|
+
const files = fs_1.default.readdirSync(dir);
|
|
226
|
+
files.forEach((file) => {
|
|
227
|
+
const filePath = path.join(dir, file);
|
|
228
|
+
const stat = fs_1.default.statSync(filePath);
|
|
229
|
+
if (stat.isDirectory()) {
|
|
230
|
+
removeOldArtifacts(filePath);
|
|
231
|
+
}
|
|
232
|
+
else if (filePath.endsWith('.ral.json') || filePath.endsWith('.ral')) {
|
|
233
|
+
fs_1.default.unlinkSync(filePath);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
if (fs_1.default.readdirSync(dir).length === 0) {
|
|
237
|
+
fs_1.default.rmdirSync(dir);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
224
240
|
class Project {
|
|
225
241
|
static buildProjectArtifact(fullNodeVersion, sourceInfos, contracts, scripts, compilerOptions) {
|
|
226
242
|
const files = new Map();
|
|
@@ -491,6 +507,9 @@ class Project {
|
|
|
491
507
|
const projectArtifact = await ProjectArtifact.from(projectRootDir);
|
|
492
508
|
if (projectArtifact === undefined ||
|
|
493
509
|
projectArtifact.needToReCompile(nodeCompilerOptions, sourceFiles, fullNodeVersion)) {
|
|
510
|
+
if (fs_1.default.existsSync(artifactsRootDir)) {
|
|
511
|
+
removeOldArtifacts(artifactsRootDir);
|
|
512
|
+
}
|
|
494
513
|
console.log(`Compiling contracts in folder "${contractsRootDir}"`);
|
|
495
514
|
Project.currentProject = await Project.compile(fullNodeVersion, provider, sourceFiles, projectRootDir, contractsRootDir, artifactsRootDir, errorOnWarnings, nodeCompilerOptions);
|
|
496
515
|
}
|
package/package.json
CHANGED
package/src/contract/contract.ts
CHANGED
|
@@ -309,6 +309,23 @@ export class ProjectArtifact {
|
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
+
function removeOldArtifacts(dir: string) {
|
|
313
|
+
const files = fs.readdirSync(dir)
|
|
314
|
+
files.forEach((file) => {
|
|
315
|
+
const filePath = path.join(dir, file)
|
|
316
|
+
const stat = fs.statSync(filePath)
|
|
317
|
+
if (stat.isDirectory()) {
|
|
318
|
+
removeOldArtifacts(filePath)
|
|
319
|
+
} else if (filePath.endsWith('.ral.json') || filePath.endsWith('.ral')) {
|
|
320
|
+
fs.unlinkSync(filePath)
|
|
321
|
+
}
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
if (fs.readdirSync(dir).length === 0) {
|
|
325
|
+
fs.rmdirSync(dir)
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
312
329
|
export class Project {
|
|
313
330
|
sourceInfos: SourceInfo[]
|
|
314
331
|
contracts: Map<string, Compiled<Contract>>
|
|
@@ -731,6 +748,9 @@ export class Project {
|
|
|
731
748
|
projectArtifact === undefined ||
|
|
732
749
|
projectArtifact.needToReCompile(nodeCompilerOptions, sourceFiles, fullNodeVersion)
|
|
733
750
|
) {
|
|
751
|
+
if (fs.existsSync(artifactsRootDir)) {
|
|
752
|
+
removeOldArtifacts(artifactsRootDir)
|
|
753
|
+
}
|
|
734
754
|
console.log(`Compiling contracts in folder "${contractsRootDir}"`)
|
|
735
755
|
Project.currentProject = await Project.compile(
|
|
736
756
|
fullNodeVersion,
|