piral-cli 1.10.3 → 1.11.0-beta.efd8b71
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/lib/apps/declaration-pilet.js +2 -2
- package/lib/apps/declaration-pilet.js.map +1 -1
- package/lib/common/declaration.d.ts +2 -2
- package/lib/common/declaration.js +6 -3
- package/lib/common/declaration.js.map +1 -1
- package/lib/common/package.d.ts +3 -1
- package/lib/common/package.js +39 -29
- package/lib/common/package.js.map +1 -1
- package/lib/common/pilet.js +2 -2
- package/lib/common/pilet.js.map +1 -1
- package/lib/external/index.js +1046 -575
- package/package.json +4 -4
- package/src/apps/declaration-pilet.ts +4 -2
- package/src/common/declaration.ts +8 -3
- package/src/common/package.ts +18 -8
- package/src/common/pilet.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0-beta.efd8b71",
|
|
4
4
|
"description": "The standard CLI for creating and building a Piral instance or a Pilet.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"portal",
|
|
@@ -72,11 +72,11 @@
|
|
|
72
72
|
"yargs": "^15"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"css-conflict-inspector": "^0.
|
|
76
|
-
"dets": "^0.
|
|
75
|
+
"css-conflict-inspector": "^0.3",
|
|
76
|
+
"dets": "^0.18",
|
|
77
77
|
"kras": "^1.0.1",
|
|
78
78
|
"open": "^10",
|
|
79
79
|
"typescript": "^5"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "efd8b7195334dd209c5bb4373873f04d823d8eea"
|
|
82
82
|
}
|
|
@@ -62,11 +62,13 @@ export async function declarationPilet(baseDir = process.cwd(), options: Declara
|
|
|
62
62
|
|
|
63
63
|
for (const item of allEntries) {
|
|
64
64
|
const targetDir = dirname(item);
|
|
65
|
-
const { peerDependencies, peerModules, root, apps, importmap } = await retrievePiletData(targetDir);
|
|
65
|
+
const { peerDependencies, peerModules, root, apps, importmap, definition } = await retrievePiletData(targetDir);
|
|
66
66
|
const piralInstances = apps.map((m) => m.appPackage.name);
|
|
67
67
|
const externals = combinePiletExternals(piralInstances, peerDependencies, peerModules, importmap);
|
|
68
68
|
const dest = resolve(root, target);
|
|
69
|
-
results.push(
|
|
69
|
+
results.push(
|
|
70
|
+
await createPiletDeclaration(piralInstances, root, definition, item, externals, dest, forceOverwrite, logLevel),
|
|
71
|
+
);
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
if (results.every(Boolean)) {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { DeclOptions, generateDeclaration, createDiffPlugin, Logger } from 'dets';
|
|
2
2
|
import { basename, dirname, extname, join, resolve } from 'path';
|
|
3
|
+
|
|
3
4
|
import { progress, log, logWarn, logVerbose, logInfo } from './log';
|
|
4
5
|
import { ForceOverwrite } from './enums';
|
|
5
|
-
import { retrievePiralRoot, retrievePiletsInfo, flattenExternals
|
|
6
|
+
import { retrievePiralRoot, retrievePiletsInfo, flattenExternals } from './package';
|
|
7
|
+
import { getRemoteTypesTarget, validateSharedDependencies } from './package';
|
|
6
8
|
import { entryModuleExtensions, piralBaseRoot, packageJson } from './constants';
|
|
7
9
|
import { readText, getEntryFiles, matchFiles, createFileIfNotExists, readJson } from './io';
|
|
8
10
|
import { getModulePath } from '../external';
|
|
9
|
-
import { LogLevels } from '../types';
|
|
11
|
+
import { LogLevels, PiletDefinition } from '../types';
|
|
10
12
|
|
|
11
13
|
const piletApiName = 'PiletApi';
|
|
12
14
|
|
|
@@ -146,6 +148,7 @@ async function createDeclarationFile(options: DeclOptions, target: string, force
|
|
|
146
148
|
export async function createPiletDeclaration(
|
|
147
149
|
piralInstances: Array<string>,
|
|
148
150
|
root: string,
|
|
151
|
+
definition: PiletDefinition,
|
|
149
152
|
entry: string,
|
|
150
153
|
allowedImports: Array<string>,
|
|
151
154
|
target: string,
|
|
@@ -159,15 +162,17 @@ export async function createPiletDeclaration(
|
|
|
159
162
|
if (file) {
|
|
160
163
|
const files = await getAllFiles([entry]);
|
|
161
164
|
const types = findDeclaredTypings(root);
|
|
165
|
+
const excluded = getRemoteTypesTarget(root, definition);
|
|
162
166
|
const options: DeclOptions = {
|
|
163
167
|
name: piralInstance,
|
|
164
168
|
root,
|
|
165
169
|
files,
|
|
166
170
|
types,
|
|
171
|
+
excluded: excluded ? [excluded] : [],
|
|
167
172
|
plugins: [createDiffPlugin(file)],
|
|
168
173
|
apis,
|
|
169
174
|
noModuleDeclaration: true,
|
|
170
|
-
imports: allowedImports.filter(m => !piralInstances.includes(m)),
|
|
175
|
+
imports: allowedImports.filter((m) => !piralInstances.includes(m)),
|
|
171
176
|
logLevel,
|
|
172
177
|
logger: createLogger(),
|
|
173
178
|
};
|
package/src/common/package.ts
CHANGED
|
@@ -16,11 +16,12 @@ import { makePiletExternals, makeExternals, findPackageRoot, findSpecificVersion
|
|
|
16
16
|
import { scaffoldFromEmulatorWebsite, updateFromEmulatorWebsite, retrieveExtraTypings } from './website';
|
|
17
17
|
import { getDependencies, getDependencyPackages, getDevDependencies } from './language';
|
|
18
18
|
import { getDevDependencyPackages, getFrameworkDependencies } from './language';
|
|
19
|
-
import { piralJsonSchemaUrl, filesTar, filesOnceTar, bundlerNames
|
|
20
|
-
import { frameworkLibs,
|
|
19
|
+
import { piralJsonSchemaUrl, filesTar, filesOnceTar, bundlerNames } from './constants';
|
|
20
|
+
import { frameworkLibs, defaultRemoteTypesTarget, packageJson } from './constants';
|
|
21
|
+
import { declarationEntryExtensions, piralJson, piletJson } from './constants';
|
|
21
22
|
import { satisfies } from './version';
|
|
22
23
|
import { getModulePath } from '../external';
|
|
23
|
-
import { PiletsInfo, SharedDependency, PiletDefinition, AppDefinition, NpmClient } from '../types';
|
|
24
|
+
import type { PiletsInfo, SharedDependency, PiletDefinition, AppDefinition, NpmClient } from '../types';
|
|
24
25
|
import type { SourceLanguage, PiralInstancePackageData, PiralInstanceDetails } from '../types';
|
|
25
26
|
import type { Framework, FileInfo, TemplateFileLocation, PiletPackageData, PiralPackageData } from '../types';
|
|
26
27
|
|
|
@@ -236,6 +237,17 @@ async function saveRemoteTypes(generatedText: string, target: string) {
|
|
|
236
237
|
}
|
|
237
238
|
}
|
|
238
239
|
|
|
240
|
+
export function getRemoteTypesTarget(rootDir: string, piletDefinition: PiletDefinition) {
|
|
241
|
+
const { remoteTypesTarget } = piletDefinition || {};
|
|
242
|
+
const proposedTarget =
|
|
243
|
+
typeof remoteTypesTarget === 'string'
|
|
244
|
+
? remoteTypesTarget
|
|
245
|
+
: remoteTypesTarget
|
|
246
|
+
? defaultRemoteTypesTarget
|
|
247
|
+
: undefined;
|
|
248
|
+
return proposedTarget ? resolve(rootDir, proposedTarget) : undefined;
|
|
249
|
+
}
|
|
250
|
+
|
|
239
251
|
async function writeRemoteTypes(
|
|
240
252
|
rootDir: string,
|
|
241
253
|
appPackages: Array<PiralInstancePackageData>,
|
|
@@ -243,14 +255,11 @@ async function writeRemoteTypes(
|
|
|
243
255
|
piletDefinition: PiletDefinition,
|
|
244
256
|
agent: Agent,
|
|
245
257
|
) {
|
|
246
|
-
const
|
|
247
|
-
const proposedTarget =
|
|
248
|
-
typeof remoteTypesTarget === 'string' ? remoteTypesTarget : remoteTypesTarget ? './src/remote.d.ts' : undefined;
|
|
258
|
+
const target = getRemoteTypesTarget(rootDir, piletDefinition);
|
|
249
259
|
|
|
250
|
-
if (
|
|
260
|
+
if (target) {
|
|
251
261
|
const snippets = await retrieveRemoteTypes(appPackages, piletPackage, agent);
|
|
252
262
|
const generatedText = combineRemoteTypes(snippets);
|
|
253
|
-
const target = resolve(rootDir, proposedTarget);
|
|
254
263
|
|
|
255
264
|
if (generatedText) {
|
|
256
265
|
await saveRemoteTypes(generatedText, target);
|
|
@@ -959,6 +968,7 @@ export async function retrievePiletData(target: string, app?: string, agent?: Ag
|
|
|
959
968
|
peerModules: piletPackage.peerModules || [],
|
|
960
969
|
ignored: checkArrayOrUndefined(piletPackage, 'preservedDependencies'),
|
|
961
970
|
schema: piletDefinition?.schemaVersion,
|
|
971
|
+
definition: piletDefinition,
|
|
962
972
|
importmap,
|
|
963
973
|
apps,
|
|
964
974
|
piletPackage,
|
package/src/common/pilet.ts
CHANGED
|
@@ -68,7 +68,7 @@ export async function triggerBuildPilet({
|
|
|
68
68
|
_,
|
|
69
69
|
}: BuildPiletOptions) {
|
|
70
70
|
const targetDir = dirname(entryModule);
|
|
71
|
-
const { peerDependencies, peerModules, root, apps, piletPackage, ignored, importmap, schema } =
|
|
71
|
+
const { peerDependencies, peerModules, root, apps, piletPackage, ignored, importmap, schema, definition } =
|
|
72
72
|
await retrievePiletData(targetDir, app);
|
|
73
73
|
const schemaVersion = originalSchemaVersion || schema || config.schemaVersion || defaultSchemaVersion;
|
|
74
74
|
const piralInstances = apps.map((m) => m.appPackage.name);
|
|
@@ -119,6 +119,7 @@ export async function triggerBuildPilet({
|
|
|
119
119
|
await createPiletDeclaration(
|
|
120
120
|
piralInstances,
|
|
121
121
|
root,
|
|
122
|
+
definition,
|
|
122
123
|
entryModule,
|
|
123
124
|
externals,
|
|
124
125
|
outDir,
|