aeria-sdk 0.0.228 → 0.0.230
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/dist/cli.js +7 -1
- package/dist/mirror.d.ts +6 -2
- package/dist/mirror.js +38 -21
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7,6 +7,10 @@ const { values: opts } = parseArgs({
|
|
|
7
7
|
type: 'boolean',
|
|
8
8
|
short: 'd',
|
|
9
9
|
},
|
|
10
|
+
runtimeOnly: {
|
|
11
|
+
type: 'boolean',
|
|
12
|
+
short: 'r',
|
|
13
|
+
},
|
|
10
14
|
},
|
|
11
15
|
});
|
|
12
16
|
export const main = async () => {
|
|
@@ -14,5 +18,7 @@ export const main = async () => {
|
|
|
14
18
|
if (opts.dev) {
|
|
15
19
|
config.environment = 'development';
|
|
16
20
|
}
|
|
17
|
-
mirrorRemotely(config
|
|
21
|
+
await mirrorRemotely(config, {
|
|
22
|
+
dts: !opts.runtimeOnly,
|
|
23
|
+
});
|
|
18
24
|
};
|
package/dist/mirror.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ type MirrorObject = {
|
|
|
4
4
|
router?: unknown;
|
|
5
5
|
};
|
|
6
6
|
export declare const runtimeContent: (config: InstanceConfig) => string;
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
7
|
+
export declare const writeRuntimeFile: (mirrorPath: string, config: InstanceConfig) => Promise<void>;
|
|
8
|
+
export declare const writeDtsFile: (mirrorPath: string, mirror: MirrorObject, config: InstanceConfig) => Promise<void>;
|
|
9
|
+
export declare const writeMirrorFiles: (mirror: MirrorObject | undefined, config: InstanceConfig) => Promise<void>;
|
|
10
|
+
export declare const mirrorRemotely: (config: InstanceConfig, options?: {
|
|
11
|
+
dts: boolean;
|
|
12
|
+
}) => Promise<void>;
|
|
9
13
|
export {};
|
package/dist/mirror.js
CHANGED
|
@@ -102,34 +102,51 @@ export const storage = getStorage(instanceConfig)
|
|
|
102
102
|
export const upload = uploader(instanceConfig)
|
|
103
103
|
export default aeria
|
|
104
104
|
\n`;
|
|
105
|
+
export const writeRuntimeFile = async (mirrorPath, config) => {
|
|
106
|
+
const syntheticRequire = createRequire(path.join(path.dirname(path.resolve(mirrorPath)), 'node_modules'));
|
|
107
|
+
let resolvedPath;
|
|
108
|
+
try {
|
|
109
|
+
resolvedPath = syntheticRequire.resolve('aeria-sdk');
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
console.warn(`couldn't locate node_modules in "${mirrorPath}"`);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const runtimeBase = path.dirname(resolvedPath);
|
|
116
|
+
const js = runtimeContent(config);
|
|
117
|
+
// this array join must be used, otherwise the .js will be transformed by the transform-import-extensions script
|
|
118
|
+
const fname = [
|
|
119
|
+
'runtime',
|
|
120
|
+
'js',
|
|
121
|
+
].join('.');
|
|
122
|
+
await writeFile(path.join(runtimeBase, fname), js);
|
|
123
|
+
if (config.environment !== 'development') {
|
|
124
|
+
await writeFile(path.join(mirrorPath, fname), js);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
export const writeDtsFile = async (mirrorPath, mirror, config) => {
|
|
128
|
+
const dts = mirrorDts(mirror, config);
|
|
129
|
+
await writeFile(path.join(mirrorPath, DTS_FILENAME), dts);
|
|
130
|
+
};
|
|
105
131
|
export const writeMirrorFiles = async (mirror, config) => {
|
|
106
132
|
const mirrorPaths = config.mirrorPaths || ['.aeria']
|
|
107
133
|
.map((mirrorPath) => path.join(process.cwd(), mirrorPath));
|
|
108
|
-
const dts = mirrorDts(mirror, config);
|
|
109
|
-
const js = runtimeContent(config);
|
|
110
134
|
for (const mirrorPath of mirrorPaths) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
resolvedPath = syntheticRequire.resolve('aeria-sdk');
|
|
135
|
+
await writeRuntimeFile(mirrorPath, config);
|
|
136
|
+
if (mirror) {
|
|
137
|
+
await writeDtsFile(mirrorPath, mirror, config);
|
|
115
138
|
}
|
|
116
|
-
catch (err) {
|
|
117
|
-
console.warn(`couldn't locate node_modules in "${mirrorPath}"`);
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
const runtimeBase = path.dirname(resolvedPath);
|
|
121
|
-
await writeFile(path.join(mirrorPath, DTS_FILENAME), dts);
|
|
122
|
-
// this array join must be used, otherwise the .js will be transformed by the transform-import-extensions script
|
|
123
|
-
await writeFile(path.join(runtimeBase, [
|
|
124
|
-
'runtime',
|
|
125
|
-
'js',
|
|
126
|
-
].join('.')), js);
|
|
127
139
|
}
|
|
128
140
|
};
|
|
129
|
-
export const mirrorRemotely = async (config
|
|
141
|
+
export const mirrorRemotely = async (config, options = {
|
|
142
|
+
dts: true,
|
|
143
|
+
}) => {
|
|
130
144
|
const aeria = createInstance(config);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
145
|
+
let mirror;
|
|
146
|
+
if (options.dts) {
|
|
147
|
+
mirror = deserialize(await aeria().describe.POST({
|
|
148
|
+
router: true,
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
134
151
|
return writeMirrorFiles(mirror, config);
|
|
135
152
|
};
|