@nu-art/build-and-install 0.400.3 → 0.400.5
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/build-and-install-v3.js +2 -1
- package/build-and-install-v3.js.map +1 -0
- package/build-and-install.js +1 -0
- package/build-and-install.js.map +1 -0
- package/core/consts.js +1 -0
- package/core/consts.js.map +1 -0
- package/core/exceptions/PhaseAggregatedException.js +1 -0
- package/core/exceptions/PhaseAggregatedException.js.map +1 -0
- package/core/package/consts.js +1 -0
- package/core/package/consts.js.map +1 -0
- package/core/params/params.d.ts +3 -2
- package/core/params/params.js +19 -8
- package/core/params/params.js.map +1 -0
- package/core/types/configs/firebasejson.js +1 -0
- package/core/types/configs/firebasejson.js.map +1 -0
- package/core/types/configs/firebaserc.js +1 -0
- package/core/types/configs/firebaserc.js.map +1 -0
- package/core/types/configs/index.js +1 -0
- package/core/types/configs/index.js.map +1 -0
- package/core/types/configs/package-json.js +1 -0
- package/core/types/configs/package-json.js.map +1 -0
- package/core/types/core.js +1 -0
- package/core/types/core.js.map +1 -0
- package/core/types/index.js +1 -0
- package/core/types/index.js.map +1 -0
- package/core/types/package/index.js +1 -0
- package/core/types/package/index.js.map +1 -0
- package/core/types/package/package.js +1 -0
- package/core/types/package/package.js.map +1 -0
- package/core/types/package/runtime-package.js +1 -0
- package/core/types/package/runtime-package.js.map +1 -0
- package/core/types/project-config.js +1 -0
- package/core/types/project-config.js.map +1 -0
- package/defaults/consts.js +1 -0
- package/defaults/consts.js.map +1 -0
- package/old/PhaseRunnerDispatcher.js +1 -0
- package/old/PhaseRunnerDispatcher.js.map +1 -0
- package/old/runner-dispatchers.js +1 -0
- package/old/runner-dispatchers.js.map +1 -0
- package/package.json +3 -3
- package/v3/PhaseManager.js +1 -0
- package/v3/PhaseManager.js.map +1 -0
- package/v3/RunningStatusHandler.js +1 -0
- package/v3/RunningStatusHandler.js.map +1 -0
- package/v3/UnitsDependencyMapper/UnitsDependencyMapper.js +2 -1
- package/v3/UnitsDependencyMapper/UnitsDependencyMapper.js.map +1 -0
- package/v3/UnitsMapper/UnitsMapper.js +1 -0
- package/v3/UnitsMapper/UnitsMapper.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_Base.js +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_Base.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseFunction.js +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseFunction.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseHosting.js +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseHosting.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_Node.js +2 -1
- package/v3/UnitsMapper/resolvers/UnitMapper_Node.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_NodeLib.js +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_NodeLib.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_NodeProject.js +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_NodeProject.js.map +1 -0
- package/v3/UnitsMapper/resolvers/index.js +1 -0
- package/v3/UnitsMapper/resolvers/index.js.map +1 -0
- package/v3/UnitsMapper/types.js +1 -0
- package/v3/UnitsMapper/types.js.map +1 -0
- package/v3/core/FilesCache.js +1 -0
- package/v3/core/FilesCache.js.map +1 -0
- package/v3/core/Unit_HelpPrinter.d.ts +1 -1
- package/v3/core/Unit_HelpPrinter.js +1 -0
- package/v3/core/Unit_HelpPrinter.js.map +1 -0
- package/v3/core/types.js +1 -0
- package/v3/core/types.js.map +1 -0
- package/v3/phase/consts.d.ts +3 -3
- package/v3/phase/consts.js +10 -8
- package/v3/phase/consts.js.map +1 -0
- package/v3/phase/index.js +1 -0
- package/v3/phase/index.js.map +1 -0
- package/v3/phase/types.js +1 -0
- package/v3/phase/types.js.map +1 -0
- package/v3/units/BaseUnit.js +1 -0
- package/v3/units/BaseUnit.js.map +1 -0
- package/v3/units/ProjectUnit.js +1 -0
- package/v3/units/ProjectUnit.js.map +1 -0
- package/v3/units/Unit_NodeProject.js +2 -1
- package/v3/units/Unit_NodeProject.js.map +1 -0
- package/v3/units/Unit_PackageJson.js +2 -1
- package/v3/units/Unit_PackageJson.js.map +1 -0
- package/v3/units/Unit_TypescriptLib.d.ts +3 -3
- package/v3/units/Unit_TypescriptLib.js +140 -19
- package/v3/units/Unit_TypescriptLib.js.map +1 -0
- package/v3/units/firebase/Unit_FirebaseFunctionsApp.js +2 -1
- package/v3/units/firebase/Unit_FirebaseFunctionsApp.js.map +1 -0
- package/v3/units/firebase/Unit_FirebaseHostingApp.js +1 -0
- package/v3/units/firebase/Unit_FirebaseHostingApp.js.map +1 -0
- package/v3/units/index.js +1 -0
- package/v3/units/index.js.map +1 -0
- package/v3/core/FileSystemUtils.d.ts +0 -34
- package/v3/core/FileSystemUtils.js +0 -151
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { promises as _fs } from 'fs';
|
|
2
|
-
import { resolve } from 'path';
|
|
3
|
-
import { BadImplementationException, exists } from '@nu-art/ts-common';
|
|
4
|
-
async function isFile(path) {
|
|
5
|
-
return (await _fs.stat(path)).isFile();
|
|
6
|
-
}
|
|
7
|
-
async function isFolder(path) {
|
|
8
|
-
return (await _fs.stat(path)).isDirectory();
|
|
9
|
-
}
|
|
10
|
-
async function assertFile(path) {
|
|
11
|
-
if (!(await isFile(path)))
|
|
12
|
-
throw new BadImplementationException(`Expected file but found directory or non-file: ${path}`);
|
|
13
|
-
}
|
|
14
|
-
async function assertFolder(path) {
|
|
15
|
-
if (!(await isFolder(path)))
|
|
16
|
-
throw new BadImplementationException(`Expected folder but found file or non-directory: ${path}`);
|
|
17
|
-
}
|
|
18
|
-
async function fileExists(path) {
|
|
19
|
-
try {
|
|
20
|
-
await _fs.access(path);
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async function assertExists(path, mustExist, type) {
|
|
28
|
-
const doesExist = await fileExists(path);
|
|
29
|
-
if (!doesExist) {
|
|
30
|
-
if (mustExist)
|
|
31
|
-
throw new BadImplementationException(`${type} does not exist: ${path}`);
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
const escapeRegExp = (string) => string.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');
|
|
37
|
-
export const DEFAULT_TEMPLATE_PATTERN = new RegExp(`\{\{(\\S*?)\}\}`);
|
|
38
|
-
export const DEFAULT_OLD_TEMPLATE_PATTERN = new RegExp(`(?<!\\\\)\\$([a-zA-Z]\\w{2,})`);
|
|
39
|
-
export const FileSystemUtils = {
|
|
40
|
-
file: {
|
|
41
|
-
exists: async (pathToFile) => {
|
|
42
|
-
return await fileExists(pathToFile);
|
|
43
|
-
},
|
|
44
|
-
delete: async (pathToFile, mustExist = false) => {
|
|
45
|
-
if (!await assertExists(pathToFile, mustExist, 'File'))
|
|
46
|
-
return;
|
|
47
|
-
await assertFile(pathToFile);
|
|
48
|
-
return _fs.rm(pathToFile);
|
|
49
|
-
},
|
|
50
|
-
write: async (pathToFile, content) => {
|
|
51
|
-
await FileSystemUtils.folder.create(resolve(pathToFile, '..'));
|
|
52
|
-
return _fs.writeFile(pathToFile, content, 'utf-8');
|
|
53
|
-
},
|
|
54
|
-
read: async (pathToFile) => {
|
|
55
|
-
await assertFile(pathToFile);
|
|
56
|
-
return _fs.readFile(pathToFile, 'utf-8');
|
|
57
|
-
},
|
|
58
|
-
copy: async (sourcePath, targetPath) => {
|
|
59
|
-
await assertExists(targetPath, false, 'File');
|
|
60
|
-
await assertFile(sourcePath);
|
|
61
|
-
await FileSystemUtils.folder.create(resolve(targetPath, '..'));
|
|
62
|
-
return _fs.copyFile(sourcePath, targetPath);
|
|
63
|
-
},
|
|
64
|
-
template: {
|
|
65
|
-
read: async (pathToFile, params, pattern = DEFAULT_TEMPLATE_PATTERN) => {
|
|
66
|
-
const content = await FileSystemUtils.file.read(pathToFile);
|
|
67
|
-
return FileSystemUtils.file.template.transform(content, params, pattern);
|
|
68
|
-
},
|
|
69
|
-
transform: (input, params, pattern = DEFAULT_TEMPLATE_PATTERN) => {
|
|
70
|
-
let match;
|
|
71
|
-
while (match = input.match(pattern)) {
|
|
72
|
-
const value = params[match[1]];
|
|
73
|
-
if (!exists(value))
|
|
74
|
-
throw new BadImplementationException(`Missing template param: ${match[1]}`);
|
|
75
|
-
const fullMatchRegex = new RegExp(escapeRegExp(match[0]), 'g');
|
|
76
|
-
input = input.replace(fullMatchRegex, value);
|
|
77
|
-
}
|
|
78
|
-
return input;
|
|
79
|
-
},
|
|
80
|
-
write: async (pathToFile, content, params, pattern = DEFAULT_TEMPLATE_PATTERN) => {
|
|
81
|
-
const transformedContent = FileSystemUtils.file.template.transform(content, params, pattern);
|
|
82
|
-
return FileSystemUtils.file.write(pathToFile, transformedContent);
|
|
83
|
-
},
|
|
84
|
-
copy: async (sourcePath, targetPath, params, pattern = DEFAULT_TEMPLATE_PATTERN) => {
|
|
85
|
-
const content = await FileSystemUtils.file.read(sourcePath);
|
|
86
|
-
const transformedContent = FileSystemUtils.file.template.transform(content, params, pattern);
|
|
87
|
-
return FileSystemUtils.file.write(targetPath, transformedContent);
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
folder: {
|
|
92
|
-
delete: async (pathToFolder, mustExist = false) => {
|
|
93
|
-
if (!await assertExists(pathToFolder, mustExist, 'Folder'))
|
|
94
|
-
return;
|
|
95
|
-
await assertFolder(pathToFolder);
|
|
96
|
-
return _fs.rm(pathToFolder, { recursive: true, force: true });
|
|
97
|
-
},
|
|
98
|
-
empty: async (pathToFolder, mustExist = true) => {
|
|
99
|
-
if (!await assertExists(pathToFolder, mustExist, 'Folder'))
|
|
100
|
-
return;
|
|
101
|
-
await assertFolder(pathToFolder);
|
|
102
|
-
const entries = await _fs.readdir(pathToFolder);
|
|
103
|
-
await Promise.all(entries.map(entry => _fs.rm(resolve(pathToFolder, entry), { recursive: true, force: true })));
|
|
104
|
-
},
|
|
105
|
-
create: async (pathToFolder) => {
|
|
106
|
-
if (await fileExists(pathToFolder))
|
|
107
|
-
return assertFolder(pathToFolder);
|
|
108
|
-
return _fs.mkdir(pathToFolder, { recursive: true });
|
|
109
|
-
},
|
|
110
|
-
list: Object.assign(async (pathToFolder) => {
|
|
111
|
-
return await _fs.readdir(pathToFolder);
|
|
112
|
-
}, {
|
|
113
|
-
forEach: Object.assign(async (pathToFolder, callback) => {
|
|
114
|
-
const entries = await _fs.readdir(pathToFolder);
|
|
115
|
-
for (const entry of entries)
|
|
116
|
-
await callback(resolve(pathToFolder, entry));
|
|
117
|
-
}, {
|
|
118
|
-
file: async (pathToFolder, callback) => {
|
|
119
|
-
await FileSystemUtils.folder.list.forEach(pathToFolder, async (entry) => {
|
|
120
|
-
if (!await isFile(entry))
|
|
121
|
-
return;
|
|
122
|
-
await callback(entry);
|
|
123
|
-
});
|
|
124
|
-
},
|
|
125
|
-
folder: async (pathToFolder, callback) => {
|
|
126
|
-
await FileSystemUtils.folder.list.forEach(pathToFolder, async (entry) => {
|
|
127
|
-
if (!await isFolder(entry))
|
|
128
|
-
return;
|
|
129
|
-
await callback(entry);
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
})
|
|
133
|
-
})
|
|
134
|
-
},
|
|
135
|
-
symlink: {
|
|
136
|
-
create: async (targetPath, linkPath) => {
|
|
137
|
-
return _fs.symlink(targetPath, linkPath);
|
|
138
|
-
},
|
|
139
|
-
delete: async (pathToLink, mustExist = false) => {
|
|
140
|
-
if (!await assertExists(pathToLink, mustExist, 'Symlink'))
|
|
141
|
-
return;
|
|
142
|
-
const stat = await _fs.lstat(pathToLink);
|
|
143
|
-
if (!stat.isSymbolicLink())
|
|
144
|
-
throw new BadImplementationException(`Expected symlink but found something else: ${pathToLink}`);
|
|
145
|
-
return _fs.unlink(pathToLink);
|
|
146
|
-
},
|
|
147
|
-
read: async (pathToLink) => {
|
|
148
|
-
return _fs.readlink(pathToLink);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
};
|