one 1.16.12 → 1.17.0
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/cjs/babel-preset/index.cjs +154 -0
- package/dist/cjs/babel-preset/index.native.js +186 -0
- package/dist/cjs/babel-preset/index.native.js.map +1 -0
- package/dist/cjs/babel-preset/index.test.cjs +143 -0
- package/dist/cjs/babel-preset/index.test.native.js +165 -0
- package/dist/cjs/babel-preset/index.test.native.js.map +1 -0
- package/dist/cjs/babel-preset/integration.test.cjs +94 -0
- package/dist/cjs/babel-preset/integration.test.native.js +97 -0
- package/dist/cjs/babel-preset/integration.test.native.js.map +1 -0
- package/dist/cjs/cli/generateBundlerConfig.cjs +247 -0
- package/dist/cjs/cli/generateBundlerConfig.native.js +316 -0
- package/dist/cjs/cli/generateBundlerConfig.native.js.map +1 -0
- package/dist/cjs/cli/generateBundlerConfig.test.cjs +350 -0
- package/dist/cjs/cli/generateBundlerConfig.test.native.js +380 -0
- package/dist/cjs/cli/generateBundlerConfig.test.native.js.map +1 -0
- package/dist/cjs/cli/patch.cjs +19 -2
- package/dist/cjs/cli/patch.native.js +26 -2
- package/dist/cjs/cli/patch.native.js.map +1 -1
- package/dist/cjs/cli/patch.test.cjs +56 -0
- package/dist/cjs/cli/patch.test.native.js +65 -0
- package/dist/cjs/cli/patch.test.native.js.map +1 -0
- package/dist/cjs/cli.cjs +39 -2
- package/dist/cjs/cli.native.js +40 -2
- package/dist/cjs/cli.native.js.map +1 -1
- package/dist/cjs/metro-config/buildOneMetroResolverOverrides.cjs +102 -0
- package/dist/cjs/metro-config/buildOneMetroResolverOverrides.native.js +109 -0
- package/dist/cjs/metro-config/buildOneMetroResolverOverrides.native.js.map +1 -0
- package/dist/cjs/metro-config/getViteMetroPluginOptions.cjs +17 -150
- package/dist/cjs/metro-config/getViteMetroPluginOptions.integration.test.cjs +84 -0
- package/dist/cjs/metro-config/getViteMetroPluginOptions.integration.test.native.js +90 -0
- package/dist/cjs/metro-config/getViteMetroPluginOptions.integration.test.native.js.map +1 -0
- package/dist/cjs/metro-config/getViteMetroPluginOptions.native.js +17 -158
- package/dist/cjs/metro-config/getViteMetroPluginOptions.native.js.map +1 -1
- package/dist/cjs/metro-config/withOne.cjs +82 -0
- package/dist/cjs/metro-config/withOne.native.js +88 -0
- package/dist/cjs/metro-config/withOne.native.js.map +1 -0
- package/dist/cjs/metro-config/withOne.test.cjs +129 -0
- package/dist/cjs/metro-config/withOne.test.native.js +156 -0
- package/dist/cjs/metro-config/withOne.test.native.js.map +1 -0
- package/dist/cjs/vite/loadConfig.cjs +20 -1
- package/dist/cjs/vite/loadConfig.native.js +20 -1
- package/dist/cjs/vite/loadConfig.native.js.map +1 -1
- package/dist/cjs/vite/plugins/warmRoutesPlugin.cjs +13 -7
- package/dist/cjs/vite/plugins/warmRoutesPlugin.native.js +13 -7
- package/dist/cjs/vite/plugins/warmRoutesPlugin.native.js.map +1 -1
- package/dist/esm/babel-preset/index.mjs +116 -0
- package/dist/esm/babel-preset/index.mjs.map +1 -0
- package/dist/esm/babel-preset/index.native.js +145 -0
- package/dist/esm/babel-preset/index.native.js.map +1 -0
- package/dist/esm/babel-preset/index.test.mjs +120 -0
- package/dist/esm/babel-preset/index.test.mjs.map +1 -0
- package/dist/esm/babel-preset/index.test.native.js +139 -0
- package/dist/esm/babel-preset/index.test.native.js.map +1 -0
- package/dist/esm/babel-preset/integration.test.mjs +71 -0
- package/dist/esm/babel-preset/integration.test.mjs.map +1 -0
- package/dist/esm/babel-preset/integration.test.native.js +71 -0
- package/dist/esm/babel-preset/integration.test.native.js.map +1 -0
- package/dist/esm/cli/generateBundlerConfig.mjs +207 -0
- package/dist/esm/cli/generateBundlerConfig.mjs.map +1 -0
- package/dist/esm/cli/generateBundlerConfig.native.js +273 -0
- package/dist/esm/cli/generateBundlerConfig.native.js.map +1 -0
- package/dist/esm/cli/generateBundlerConfig.test.mjs +327 -0
- package/dist/esm/cli/generateBundlerConfig.test.mjs.map +1 -0
- package/dist/esm/cli/generateBundlerConfig.test.native.js +354 -0
- package/dist/esm/cli/generateBundlerConfig.test.native.js.map +1 -0
- package/dist/esm/cli/patch.mjs +19 -2
- package/dist/esm/cli/patch.mjs.map +1 -1
- package/dist/esm/cli/patch.native.js +26 -2
- package/dist/esm/cli/patch.native.js.map +1 -1
- package/dist/esm/cli/patch.test.mjs +57 -0
- package/dist/esm/cli/patch.test.mjs.map +1 -0
- package/dist/esm/cli/patch.test.native.js +63 -0
- package/dist/esm/cli/patch.test.native.js.map +1 -0
- package/dist/esm/cli.mjs +39 -2
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/cli.native.js +40 -2
- package/dist/esm/cli.native.js.map +1 -1
- package/dist/esm/metro-config/buildOneMetroResolverOverrides.mjs +66 -0
- package/dist/esm/metro-config/buildOneMetroResolverOverrides.mjs.map +1 -0
- package/dist/esm/metro-config/buildOneMetroResolverOverrides.native.js +70 -0
- package/dist/esm/metro-config/buildOneMetroResolverOverrides.native.js.map +1 -0
- package/dist/esm/metro-config/getViteMetroPluginOptions.integration.test.mjs +61 -0
- package/dist/esm/metro-config/getViteMetroPluginOptions.integration.test.mjs.map +1 -0
- package/dist/esm/metro-config/getViteMetroPluginOptions.integration.test.native.js +64 -0
- package/dist/esm/metro-config/getViteMetroPluginOptions.integration.test.native.js.map +1 -0
- package/dist/esm/metro-config/getViteMetroPluginOptions.mjs +17 -138
- package/dist/esm/metro-config/getViteMetroPluginOptions.mjs.map +1 -1
- package/dist/esm/metro-config/getViteMetroPluginOptions.native.js +17 -146
- package/dist/esm/metro-config/getViteMetroPluginOptions.native.js.map +1 -1
- package/dist/esm/metro-config/withOne.mjs +45 -0
- package/dist/esm/metro-config/withOne.mjs.map +1 -0
- package/dist/esm/metro-config/withOne.native.js +48 -0
- package/dist/esm/metro-config/withOne.native.js.map +1 -0
- package/dist/esm/metro-config/withOne.test.mjs +106 -0
- package/dist/esm/metro-config/withOne.test.mjs.map +1 -0
- package/dist/esm/metro-config/withOne.test.native.js +130 -0
- package/dist/esm/metro-config/withOne.test.native.js.map +1 -0
- package/dist/esm/vite/loadConfig.mjs +20 -1
- package/dist/esm/vite/loadConfig.mjs.map +1 -1
- package/dist/esm/vite/loadConfig.native.js +20 -1
- package/dist/esm/vite/loadConfig.native.js.map +1 -1
- package/dist/esm/vite/plugins/warmRoutesPlugin.mjs +13 -7
- package/dist/esm/vite/plugins/warmRoutesPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/warmRoutesPlugin.native.js +13 -7
- package/dist/esm/vite/plugins/warmRoutesPlugin.native.js.map +1 -1
- package/package.json +20 -9
- package/src/babel-preset/index.test.ts +148 -0
- package/src/babel-preset/index.ts +250 -0
- package/src/babel-preset/integration.test.ts +91 -0
- package/src/cli/generateBundlerConfig.test.ts +343 -0
- package/src/cli/generateBundlerConfig.ts +339 -0
- package/src/cli/patch.test.ts +65 -0
- package/src/cli/patch.ts +30 -2
- package/src/cli.ts +31 -0
- package/src/metro-config/buildOneMetroResolverOverrides.ts +104 -0
- package/src/metro-config/getViteMetroPluginOptions.integration.test.ts +75 -0
- package/src/metro-config/getViteMetroPluginOptions.ts +15 -230
- package/src/metro-config/withOne.test.ts +120 -0
- package/src/metro-config/withOne.ts +112 -0
- package/src/vite/loadConfig.ts +22 -0
- package/src/vite/plugins/warmRoutesPlugin.ts +22 -6
- package/types/babel-preset/index.d.ts +68 -0
- package/types/babel-preset/index.d.ts.map +1 -0
- package/types/babel-preset/index.test.d.ts +2 -0
- package/types/babel-preset/index.test.d.ts.map +1 -0
- package/types/babel-preset/integration.test.d.ts +2 -0
- package/types/babel-preset/integration.test.d.ts.map +1 -0
- package/types/cli/generateBundlerConfig.d.ts +61 -0
- package/types/cli/generateBundlerConfig.d.ts.map +1 -0
- package/types/cli/generateBundlerConfig.test.d.ts +2 -0
- package/types/cli/generateBundlerConfig.test.d.ts.map +1 -0
- package/types/cli/patch.d.ts.map +1 -1
- package/types/cli/patch.test.d.ts +2 -0
- package/types/cli/patch.test.d.ts.map +1 -0
- package/types/metro-config/buildOneMetroResolverOverrides.d.ts +20 -0
- package/types/metro-config/buildOneMetroResolverOverrides.d.ts.map +1 -0
- package/types/metro-config/getViteMetroPluginOptions.d.ts +0 -5
- package/types/metro-config/getViteMetroPluginOptions.d.ts.map +1 -1
- package/types/metro-config/getViteMetroPluginOptions.integration.test.d.ts +2 -0
- package/types/metro-config/getViteMetroPluginOptions.integration.test.d.ts.map +1 -0
- package/types/metro-config/withOne.d.ts +44 -0
- package/types/metro-config/withOne.d.ts.map +1 -0
- package/types/metro-config/withOne.test.d.ts +2 -0
- package/types/metro-config/withOne.test.d.ts.map +1 -0
- package/types/vite/loadConfig.d.ts +1 -0
- package/types/vite/loadConfig.d.ts.map +1 -1
- package/types/vite/plugins/warmRoutesPlugin.d.ts.map +1 -1
- package/dist/cjs/metro-config/getViteMetroPluginOptions.test.cjs +0 -23
- package/dist/cjs/metro-config/getViteMetroPluginOptions.test.native.js +0 -26
- package/dist/cjs/metro-config/getViteMetroPluginOptions.test.native.js.map +0 -1
- package/dist/esm/metro-config/getViteMetroPluginOptions.test.mjs +0 -24
- package/dist/esm/metro-config/getViteMetroPluginOptions.test.mjs.map +0 -1
- package/dist/esm/metro-config/getViteMetroPluginOptions.test.native.js +0 -24
- package/dist/esm/metro-config/getViteMetroPluginOptions.test.native.js.map +0 -1
- package/src/metro-config/getViteMetroPluginOptions.test.ts +0 -34
- package/types/metro-config/getViteMetroPluginOptions.test.d.ts +0 -2
- package/types/metro-config/getViteMetroPluginOptions.test.d.ts.map +0 -1
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
+
get: () => from[key],
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
36
|
+
var generateBundlerConfig_exports = {};
|
|
37
|
+
__export(generateBundlerConfig_exports, {
|
|
38
|
+
ONE_GENERATED_MARKER: () => ONE_GENERATED_MARKER,
|
|
39
|
+
generateBundlerConfig: () => generateBundlerConfig,
|
|
40
|
+
getBundlerConfigOptionsFromOneOptions: () => getBundlerConfigOptionsFromOneOptions,
|
|
41
|
+
isCiEnvironment: () => isCiEnvironment,
|
|
42
|
+
maybeGenerateBundlerConfigOnInstall: () => maybeGenerateBundlerConfigOnInstall
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(generateBundlerConfig_exports);
|
|
45
|
+
var import_fs = require("fs");
|
|
46
|
+
var import_module = __toESM(require("module"), 1);
|
|
47
|
+
var import_path = __toESM(require("path"), 1);
|
|
48
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
49
|
+
var import_getRouterRootFromOneOptions = require("../utils/getRouterRootFromOneOptions.native.js");
|
|
50
|
+
function _type_of(obj) {
|
|
51
|
+
"@swc/helpers - typeof";
|
|
52
|
+
|
|
53
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
54
|
+
}
|
|
55
|
+
var ONE_GENERATED_MARKER = "@one/generated bundler-config";
|
|
56
|
+
function buildBabelConfigContent(param) {
|
|
57
|
+
var {
|
|
58
|
+
eject,
|
|
59
|
+
options
|
|
60
|
+
} = param;
|
|
61
|
+
var header = eject ? `// you own this file. edit freely \u2014 \`one\` will not regenerate it.
|
|
62
|
+
// delegates to one/babel-preset which holds the canonical plugin chain.
|
|
63
|
+
` : `// ${ONE_GENERATED_MARKER}
|
|
64
|
+
//
|
|
65
|
+
// auto-generated by \`one patch\` on ci/eas workers when expo-updates is
|
|
66
|
+
// in deps. delegates to one/babel-preset so expo export / eas update
|
|
67
|
+
// use the same router/setup options as \`one dev\` and \`one build\`.
|
|
68
|
+
//
|
|
69
|
+
// to customize, delete this header and edit freely \u2014 re-runs will then
|
|
70
|
+
// leave this file alone.
|
|
71
|
+
`;
|
|
72
|
+
return `${header}
|
|
73
|
+
const oneBabelPreset = require('one/babel-preset')
|
|
74
|
+
const preset = oneBabelPreset.default || oneBabelPreset
|
|
75
|
+
const oneBundlerOptions = ${serializeBundlerConfigOptions(options)}
|
|
76
|
+
|
|
77
|
+
module.exports = function (api) {
|
|
78
|
+
return preset(api, oneBundlerOptions)
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
}
|
|
82
|
+
function buildMetroConfigContent(param) {
|
|
83
|
+
var {
|
|
84
|
+
eject,
|
|
85
|
+
options
|
|
86
|
+
} = param;
|
|
87
|
+
var header = eject ? `// you own this file. edit freely \u2014 \`one\` will not regenerate it.
|
|
88
|
+
// withOne() invokes the same Metro pipeline One uses for production bundles.
|
|
89
|
+
` : `// ${ONE_GENERATED_MARKER}
|
|
90
|
+
//
|
|
91
|
+
// auto-generated by \`one patch\` on ci/eas workers when expo-updates is
|
|
92
|
+
// in deps. delegates to one/metro-config which invokes the exact same
|
|
93
|
+
// metro pipeline one uses for production native bundles with your
|
|
94
|
+
// router/setup options \u2014 no separate expo/metro-config setup needed.
|
|
95
|
+
//
|
|
96
|
+
// to customize, delete this header and edit freely \u2014 re-runs will then
|
|
97
|
+
// leave this file alone.
|
|
98
|
+
`;
|
|
99
|
+
return `${header}
|
|
100
|
+
const { withOne } = require('one/metro-config')
|
|
101
|
+
const oneBundlerOptions = ${serializeBundlerConfigOptions(options)}
|
|
102
|
+
|
|
103
|
+
module.exports = withOne(__dirname, oneBundlerOptions)
|
|
104
|
+
`;
|
|
105
|
+
}
|
|
106
|
+
var FILES = [{
|
|
107
|
+
name: "babel.config.cjs",
|
|
108
|
+
getContent: buildBabelConfigContent,
|
|
109
|
+
conflicting: ["babel.config.js", "babel.config.mjs", ".babelrc", ".babelrc.js"]
|
|
110
|
+
}, {
|
|
111
|
+
name: "metro.config.cjs",
|
|
112
|
+
getContent: buildMetroConfigContent,
|
|
113
|
+
conflicting: ["metro.config.js", "metro.config.mjs"]
|
|
114
|
+
}];
|
|
115
|
+
function stripUndefined(value) {
|
|
116
|
+
if (Array.isArray(value)) {
|
|
117
|
+
return value.map(stripUndefined);
|
|
118
|
+
}
|
|
119
|
+
if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
|
|
120
|
+
return Object.fromEntries(Object.entries(value).filter(function (param) {
|
|
121
|
+
var [, entry] = param;
|
|
122
|
+
return entry !== void 0;
|
|
123
|
+
}).map(function (param) {
|
|
124
|
+
var [key, entry] = param;
|
|
125
|
+
return [key, stripUndefined(entry)];
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
function assertSerializable(value) {
|
|
131
|
+
var keyPath = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "one bundler options";
|
|
132
|
+
if (typeof value === "function" || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "symbol" || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "bigint") {
|
|
133
|
+
throw new Error(`[one] ${keyPath} must be JSON-serializable to generate Babel/Metro config files. Move function-valued native linking/customization into an ejected config.`);
|
|
134
|
+
}
|
|
135
|
+
if (Array.isArray(value)) {
|
|
136
|
+
value.forEach(function (entry2, index) {
|
|
137
|
+
return assertSerializable(entry2, `${keyPath}[${index}]`);
|
|
138
|
+
});
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
|
|
142
|
+
var _iteratorNormalCompletion = true,
|
|
143
|
+
_didIteratorError = false,
|
|
144
|
+
_iteratorError = void 0;
|
|
145
|
+
try {
|
|
146
|
+
for (var _iterator = Object.entries(value)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
147
|
+
var [key, entry] = _step.value;
|
|
148
|
+
assertSerializable(entry, `${keyPath}.${key}`);
|
|
149
|
+
}
|
|
150
|
+
} catch (err) {
|
|
151
|
+
_didIteratorError = true;
|
|
152
|
+
_iteratorError = err;
|
|
153
|
+
} finally {
|
|
154
|
+
try {
|
|
155
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
156
|
+
_iterator.return();
|
|
157
|
+
}
|
|
158
|
+
} finally {
|
|
159
|
+
if (_didIteratorError) {
|
|
160
|
+
throw _iteratorError;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function serializeBundlerConfigOptions(options) {
|
|
167
|
+
var clean = stripUndefined(options);
|
|
168
|
+
assertSerializable(clean);
|
|
169
|
+
return JSON.stringify(clean, null, 2);
|
|
170
|
+
}
|
|
171
|
+
function getBundlerConfigOptionsFromOneOptions() {
|
|
172
|
+
var oneOptions = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
173
|
+
var _oneOptions_router, _oneOptions_router1;
|
|
174
|
+
return stripUndefined({
|
|
175
|
+
routerRoot: (0, import_getRouterRootFromOneOptions.getRouterRootFromOneOptions)(oneOptions),
|
|
176
|
+
ignoredRouteFiles: (_oneOptions_router = oneOptions.router) === null || _oneOptions_router === void 0 ? void 0 : _oneOptions_router.ignoredRouteFiles,
|
|
177
|
+
linking: (_oneOptions_router1 = oneOptions.router) === null || _oneOptions_router1 === void 0 ? void 0 : _oneOptions_router1.linking,
|
|
178
|
+
setupFile: oneOptions.setupFile
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
function generateBundlerConfig() {
|
|
182
|
+
var args = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
183
|
+
var _args_cwd;
|
|
184
|
+
var cwd = import_path.default.resolve((_args_cwd = args.cwd) !== null && _args_cwd !== void 0 ? _args_cwd : process.cwd());
|
|
185
|
+
var force = !!args.force;
|
|
186
|
+
var check = !!args.check;
|
|
187
|
+
var quiet = !!args.quiet;
|
|
188
|
+
var log = function (msg) {
|
|
189
|
+
if (!quiet) console.info(msg);
|
|
190
|
+
};
|
|
191
|
+
var warn = function (msg) {
|
|
192
|
+
if (!quiet) console.warn(msg);
|
|
193
|
+
};
|
|
194
|
+
var results = [];
|
|
195
|
+
var eject = !!args.eject;
|
|
196
|
+
var bundlerOptions = getBundlerConfigOptionsFromOneOptions(args.oneOptions);
|
|
197
|
+
var _iteratorNormalCompletion = true,
|
|
198
|
+
_didIteratorError = false,
|
|
199
|
+
_iteratorError = void 0;
|
|
200
|
+
try {
|
|
201
|
+
for (var _iterator = FILES[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
202
|
+
var file = _step.value;
|
|
203
|
+
var filePath = import_path.default.join(cwd, file.name);
|
|
204
|
+
var targetContent = file.getContent({
|
|
205
|
+
eject,
|
|
206
|
+
options: bundlerOptions
|
|
207
|
+
});
|
|
208
|
+
var conflict = file.conflicting.find(function (alt) {
|
|
209
|
+
return (0, import_fs.existsSync)(import_path.default.join(cwd, alt));
|
|
210
|
+
});
|
|
211
|
+
if (conflict && !(0, import_fs.existsSync)(filePath)) {
|
|
212
|
+
results.push({
|
|
213
|
+
filePath: import_path.default.join(cwd, conflict),
|
|
214
|
+
action: "skipped-other-format",
|
|
215
|
+
reason: `Found ${conflict}; not creating ${file.name}. To switch, delete ${conflict} and re-run with --force.`
|
|
216
|
+
});
|
|
217
|
+
warn(import_picocolors.default.yellow(`[one] found ${conflict} \u2014 leaving it alone. Delete it and re-run with --force to switch to ${file.name}.`));
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
if (!(0, import_fs.existsSync)(filePath)) {
|
|
221
|
+
if (check) {
|
|
222
|
+
results.push({
|
|
223
|
+
filePath,
|
|
224
|
+
action: "would-write"
|
|
225
|
+
});
|
|
226
|
+
log(import_picocolors.default.yellow(`[one] missing: ${file.name}`));
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
(0, import_fs.writeFileSync)(filePath, targetContent);
|
|
230
|
+
results.push({
|
|
231
|
+
filePath,
|
|
232
|
+
action: "wrote"
|
|
233
|
+
});
|
|
234
|
+
log(import_picocolors.default.green(`[one] wrote ${file.name}`));
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
var existing = (0, import_fs.readFileSync)(filePath, "utf8");
|
|
238
|
+
if (existing === targetContent) {
|
|
239
|
+
results.push({
|
|
240
|
+
filePath,
|
|
241
|
+
action: "kept"
|
|
242
|
+
});
|
|
243
|
+
log(import_picocolors.default.dim(`[one] up to date: ${file.name}`));
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
var hasMarker = existing.includes(ONE_GENERATED_MARKER);
|
|
247
|
+
if (!hasMarker && !force) {
|
|
248
|
+
results.push({
|
|
249
|
+
filePath,
|
|
250
|
+
action: "skipped-customized",
|
|
251
|
+
reason: `${file.name} has been customized (no @one marker). Re-add the marker comment or pass --force to overwrite.`
|
|
252
|
+
});
|
|
253
|
+
warn(import_picocolors.default.yellow(`[one] ${file.name} appears customized \u2014 skipping. Pass --force to overwrite.`));
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
if (check) {
|
|
257
|
+
results.push({
|
|
258
|
+
filePath,
|
|
259
|
+
action: "would-overwrite"
|
|
260
|
+
});
|
|
261
|
+
log(import_picocolors.default.yellow(`[one] out of date: ${file.name}`));
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
(0, import_fs.writeFileSync)(filePath, targetContent);
|
|
265
|
+
results.push({
|
|
266
|
+
filePath,
|
|
267
|
+
action: "wrote"
|
|
268
|
+
});
|
|
269
|
+
log(import_picocolors.default.green(`[one] updated ${file.name}`));
|
|
270
|
+
}
|
|
271
|
+
} catch (err) {
|
|
272
|
+
_didIteratorError = true;
|
|
273
|
+
_iteratorError = err;
|
|
274
|
+
} finally {
|
|
275
|
+
try {
|
|
276
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
277
|
+
_iterator.return();
|
|
278
|
+
}
|
|
279
|
+
} finally {
|
|
280
|
+
if (_didIteratorError) {
|
|
281
|
+
throw _iteratorError;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
var acceptableAlways = /* @__PURE__ */new Set(["wrote", "kept", "skipped-other-format", "skipped-customized"]);
|
|
286
|
+
var acceptableInCheck = /* @__PURE__ */new Set(["kept", "skipped-other-format", "skipped-customized"]);
|
|
287
|
+
var ok = (check ? acceptableInCheck : acceptableAlways).size ? results.every(function (r) {
|
|
288
|
+
return (check ? acceptableInCheck : acceptableAlways).has(r.action);
|
|
289
|
+
}) : false;
|
|
290
|
+
return {
|
|
291
|
+
results,
|
|
292
|
+
ok
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function isCiEnvironment() {
|
|
296
|
+
var truthy = function (v) {
|
|
297
|
+
return !!v && v !== "false" && v !== "0";
|
|
298
|
+
};
|
|
299
|
+
return truthy(process.env.EAS_BUILD) || truthy(process.env.CI);
|
|
300
|
+
}
|
|
301
|
+
function maybeGenerateBundlerConfigOnInstall() {
|
|
302
|
+
var cwd = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.cwd(),
|
|
303
|
+
oneOptions = arguments.length > 1 ? arguments[1] : void 0;
|
|
304
|
+
if (!isCiEnvironment()) return;
|
|
305
|
+
try {
|
|
306
|
+
import_module.default.createRequire(cwd + "/").resolve("expo-updates/package.json");
|
|
307
|
+
} catch (unused) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
generateBundlerConfig({
|
|
311
|
+
cwd,
|
|
312
|
+
quiet: false,
|
|
313
|
+
oneOptions
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
//# sourceMappingURL=generateBundlerConfig.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","generateBundlerConfig_exports","__export","ONE_GENERATED_MARKER","generateBundlerConfig","getBundlerConfigOptionsFromOneOptions","isCiEnvironment","maybeGenerateBundlerConfigOnInstall","module","exports","import_fs","require","import_module","__toESM","import_path","import_picocolors","import_getRouterRootFromOneOptions","_type_of","obj","Symbol","constructor","buildBabelConfigContent","param","eject","options","header","serializeBundlerConfigOptions","buildMetroConfigContent","FILES","name","getContent","conflicting","stripUndefined","Array","isArray","map","Object","fromEntries","entries","filter","entry","key","assertSerializable","keyPath","arguments","length","Error","forEach","entry2","index","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","iterator","_step","next","done","err","return","clean","JSON","stringify","oneOptions","_oneOptions_router","_oneOptions_router1","routerRoot","getRouterRootFromOneOptions","ignoredRouteFiles","router","linking","setupFile","args","_args_cwd","cwd","default","resolve","process","force","check","quiet","log","msg","console","info","warn","results","bundlerOptions","file","filePath","join","targetContent","conflict","find","alt","existsSync","push","action","reason","yellow","writeFileSync","green","existing","readFileSync","dim","hasMarker","includes"],"sources":["../../../src/cli/generateBundlerConfig.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,6BAAA;AAAAC,QAAA,CAAAD,6BAAA;EAAAE,oBAAA,EAAAA,CAAA,KAAAA,oBAAA;EAAAC,qBAAA,EAAAA,CAAA,KAAAA,qBAAA;EAAAC,qCAAA,EAAAA,CAAA,KAAAA,qCAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,mCAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAb,YAAwD,CAAAK,6BAAA;AACxD,IAAAS,SAAA,GAAAC,OAAA,KAAuB;AACvB,IAAAC,aAAA,GAAAC,OAAiB,CAAAF,OAAA;AACjB,IAAAG,WAAA,GAAAD,OAAmB,CAAAF,OAAA;AACnB,IAAAI,iBAAA,GAAAF,OAAA,CAAAF,OAAA,aAA4C;AAQrC,IAAAK,kCAA6B,GAAAL,OAAA;AASpC,SAASM,SAAAC,GAAA;EACP;;EACA,OAAAA,GAAA,WAAAC,MAAA,oBAAAD,GAAA,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AACF;AAIE,IAAAf,oBAAe,GACX;AAAA,SAAAkB,wBAAAC,KAAA;EAAA,IAGA;IAAAC,KAAM;IAAAC;EAAA,IAAAF,KAAoB;EAAA,IAAAG,MAAA,GAAAF,KAAA;AAAA;AAAA,UAAApB,oBAAA;AAAA;AAAA;AAA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AA,CAAA4D,OAAA,CAAAwB,MAAA,mBAAAX,IAAA,CAAA3D,IAAA;UACA;QACD;QACK,IAAAnB,SAAM,CAAQ0F,aAAA,EAAAX,QAAoB,EAAAE,aAAkB;QACvCL,OACZ,CAAAU,IAAQ;UAEXP,QAAA;UAEGQ,MAAE;QACX;QAYOhB,GAAS,CAAAlE,iBAA2B,CAAA4D,OAAA,CAAA0B,KAAA,gBAAAb,IAAA,CAAA3D,IAAA;QACnC;MAEN;MACF,IAAAyE,QAAA,OAAA5F,SAAA,CAAA6F,YAAA,EAAAd,QAAA;MASO,IAASa,QAAA,KAAAX,aAAA;QAITL,OAAA,CAAAU,IAAA;UAIDP,QAAA;UACFQ,MAAA;QAGF,EAAQ;QACNhB,GAAA,CAAAlE,iBAAA,CAAA4D,OAAA,CAAA6B,GAAA,sBAAAhB,IAAA,CAAA3D,IAAA;QACF;MAEA;MACF,IAAA4E,SAAA,GAAAH,QAAA,CAAAI,QAAA,CAAAvG,oBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
+
get: () => from[key],
|
|
11
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
+
value: mod,
|
|
23
|
+
enumerable: true
|
|
24
|
+
}) : target, mod));
|
|
25
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
26
|
+
var import_node_os = __toESM(require("node:os"), 1);
|
|
27
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
28
|
+
var import_vitest = require("vitest");
|
|
29
|
+
var import_generateBundlerConfig = require("./generateBundlerConfig.cjs");
|
|
30
|
+
(0, import_vitest.describe)("generateBundlerConfig", () => {
|
|
31
|
+
let tmpDir;
|
|
32
|
+
(0, import_vitest.beforeEach)(() => {
|
|
33
|
+
tmpDir = import_node_fs.default.mkdtempSync(import_node_path.default.join(import_node_os.default.tmpdir(), "one-gen-bundler-test-"));
|
|
34
|
+
});
|
|
35
|
+
(0, import_vitest.afterEach)(() => {
|
|
36
|
+
import_node_fs.default.rmSync(tmpDir, {
|
|
37
|
+
recursive: true,
|
|
38
|
+
force: true
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
(0, import_vitest.it)("writes both files when missing", () => {
|
|
42
|
+
const {
|
|
43
|
+
ok,
|
|
44
|
+
results
|
|
45
|
+
} = (0, import_generateBundlerConfig.generateBundlerConfig)({
|
|
46
|
+
cwd: tmpDir,
|
|
47
|
+
quiet: true
|
|
48
|
+
});
|
|
49
|
+
(0, import_vitest.expect)(ok).toBe(true);
|
|
50
|
+
(0, import_vitest.expect)(results.map(r => r.action)).toEqual(["wrote", "wrote"]);
|
|
51
|
+
const babel = import_node_fs.default.readFileSync(import_node_path.default.join(tmpDir, "babel.config.cjs"), "utf8");
|
|
52
|
+
(0, import_vitest.expect)(babel).toContain(import_generateBundlerConfig.ONE_GENERATED_MARKER);
|
|
53
|
+
(0, import_vitest.expect)(babel).toContain("require('one/babel-preset')");
|
|
54
|
+
(0, import_vitest.expect)(babel).toContain("oneBundlerOptions");
|
|
55
|
+
const metro = import_node_fs.default.readFileSync(import_node_path.default.join(tmpDir, "metro.config.cjs"), "utf8");
|
|
56
|
+
(0, import_vitest.expect)(metro).toContain(import_generateBundlerConfig.ONE_GENERATED_MARKER);
|
|
57
|
+
(0, import_vitest.expect)(metro).toContain("require('one/metro-config')");
|
|
58
|
+
(0, import_vitest.expect)(metro).toContain("withOne");
|
|
59
|
+
});
|
|
60
|
+
(0, import_vitest.it)("is idempotent on second run", () => {
|
|
61
|
+
(0, import_generateBundlerConfig.generateBundlerConfig)({
|
|
62
|
+
cwd: tmpDir,
|
|
63
|
+
quiet: true
|
|
64
|
+
});
|
|
65
|
+
const before = import_node_fs.default.readFileSync(import_node_path.default.join(tmpDir, "babel.config.cjs"), "utf8");
|
|
66
|
+
const {
|
|
67
|
+
results
|
|
68
|
+
} = (0, import_generateBundlerConfig.generateBundlerConfig)({
|
|
69
|
+
cwd: tmpDir,
|
|
70
|
+
quiet: true
|
|
71
|
+
});
|
|
72
|
+
(0, import_vitest.expect)(results.map(r => r.action)).toEqual(["kept", "kept"]);
|
|
73
|
+
const after = import_node_fs.default.readFileSync(import_node_path.default.join(tmpDir, "babel.config.cjs"), "utf8");
|
|
74
|
+
(0, import_vitest.expect)(after).toBe(before);
|
|
75
|
+
});
|
|
76
|
+
(0, import_vitest.it)("refuses to overwrite a customized file without --force", () => {
|
|
77
|
+
import_node_fs.default.writeFileSync(import_node_path.default.join(tmpDir, "babel.config.cjs"), "// hand-written\nmodule.exports = { presets: [] }\n");
|
|
78
|
+
const {
|
|
79
|
+
ok,
|
|
80
|
+
results
|
|
81
|
+
} = (0, import_generateBundlerConfig.generateBundlerConfig)({
|
|
82
|
+
cwd: tmpDir,
|
|
83
|
+
quiet: true
|
|
84
|
+
});
|
|
85
|
+
const babelResult = results.find(r => r.filePath.endsWith("babel.config.cjs"));
|
|
86
|
+
(0, import_vitest.expect)(babelResult.action).toBe("skipped-customized");
|
|
87
|
+
(0, import_vitest.expect)(ok).toBe(true);
|
|
88
|
+
const after = import_node_fs.default.readFileSync(import_node_path.default.join(tmpDir, "babel.config.cjs"), "utf8");
|
|
89
|
+
(0, import_vitest.expect)(after).toContain("hand-written");
|
|
90
|
+
});
|
|
91
|
+
(0, import_vitest.it)("overwrites a customized file when --force is set", () => {
|
|
92
|
+
import_node_fs.default.writeFileSync(import_node_path.default.join(tmpDir, "babel.config.cjs"), "// hand-written\nmodule.exports = { presets: [] }\n");
|
|
93
|
+
const {
|
|
94
|
+
results
|
|
95
|
+
} = (0, import_generateBundlerConfig.generateBundlerConfig)({
|
|
96
|
+
cwd: tmpDir,
|
|
97
|
+
force: true,
|
|
98
|
+
quiet: true
|
|
99
|
+
});
|
|
100
|
+
const babelResult = results.find(r => r.filePath.endsWith("babel.config.cjs"));
|
|
101
|
+
(0, import_vitest.expect)(babelResult.action).toBe("wrote");
|
|
102
|
+
const after = import_node_fs.default.readFileSync(import_node_path.default.join(tmpDir, "babel.config.cjs"), "utf8");
|
|
103
|
+
(0, import_vitest.expect)(after).toContain(import_generateBundlerConfig.ONE_GENERATED_MARKER);
|
|
104
|
+
(0, import_vitest.expect)(after).not.toContain("hand-written");
|
|
105
|
+
});
|
|
106
|
+
(0, import_vitest.it)("rewrites a stale marked file", () => {
|
|
107
|
+
import_node_fs.default.writeFileSync(import_node_path.default.join(tmpDir, "babel.config.cjs"), `// ${import_generateBundlerConfig.ONE_GENERATED_MARKER}
|
|
108
|
+
// old content from previous version
|
|
109
|
+
module.exports = {}
|
|
110
|
+
`);
|
|
111
|
+
const {
|
|
112
|
+
results
|
|
113
|
+
} = (0, import_generateBundlerConfig.generateBundlerConfig)({
|
|
114
|
+
cwd: tmpDir,
|
|
115
|
+
quiet: true
|
|
116
|
+
});
|
|
117
|
+
const babelResult = results.find(r => r.filePath.endsWith("babel.config.cjs"));
|
|
118
|
+
(0, import_vitest.expect)(babelResult.action).toBe("wrote");
|
|
119
|
+
const after = import_node_fs.default.readFileSync(import_node_path.default.join(tmpDir, "babel.config.cjs"), "utf8");
|
|
120
|
+
(0, import_vitest.expect)(after).toContain("require('one/babel-preset')");
|
|
121
|
+
(0, import_vitest.expect)(after).not.toContain("old content from previous version");
|
|
122
|
+
});
|
|
123
|
+
(0, import_vitest.describe)("--check mode", () => {
|
|
124
|
+
(0, import_vitest.it)("exits ok when files exist and match", () => {
|
|
125
|
+
(0, import_generateBundlerConfig.generateBundlerConfig)({
|
|
126
|
+
cwd: tmpDir,
|
|
127
|
+
quiet: true
|
|
128
|
+
});
|
|
129
|
+
const {
|
|
130
|
+
ok,
|
|
131
|
+
results
|
|
132
|
+
} = (0, import_generateBundlerConfig.generateBundlerConfig)({
|
|
133
|
+
cwd: tmpDir,
|
|
134
|
+
check: true,
|
|
135
|
+
quiet: true
|
|
136
|
+
});
|
|
137
|
+
(0, import_vitest.expect)(ok).toBe(true);
|
|
138
|
+
(0, import_vitest.expect)(results.every(r => r.action === "kept")).toBe(true);
|
|
139
|
+
});
|
|
140
|
+
(0, import_vitest.it)("exits not-ok when files are missing", () => {
|
|
141
|
+
const {
|
|
142
|
+
ok,
|
|
143
|
+
results
|
|
144
|
+
} = (0, import_generateBundlerConfig.generateBundlerConfig)({
|
|
145
|
+
cwd: tmpDir,
|
|
146
|
+
check: true,
|
|
147
|
+
quiet: true
|
|
148
|
+
});
|
|
149
|
+
(0, import_vitest.expect)(ok).toBe(false);
|
|
150
|
+
(0, import_vitest.expect)(results.every(r => r.action === "would-write")).toBe(true);
|
|
151
|
+
(0, import_vitest.expect)(import_node_fs.default.existsSync(import_node_path.default.join(tmpDir, "babel.config.cjs"))).toBe(false);
|
|
152
|
+
});
|
|
153
|
+
(0, import_vitest.it)("exits not-ok when a marked file is stale", () => {
|
|
154
|
+
import_node_fs.default.writeFileSync(import_node_path.default.join(tmpDir, "babel.config.cjs"), `// ${import_generateBundlerConfig.ONE_GENERATED_MARKER}
|
|
155
|
+
module.exports = {}
|
|
156
|
+
`);
|
|
157
|
+
import_node_fs.default.writeFileSync(import_node_path.default.join(tmpDir, "metro.config.cjs"), `// ${import_generateBundlerConfig.ONE_GENERATED_MARKER}
|
|
158
|
+
module.exports = {}
|
|
159
|
+
`);
|
|
160
|
+
const {
|
|
161
|
+
ok,
|
|
162
|
+
results
|
|
163
|
+
} = (0, import_generateBundlerConfig.generateBundlerConfig)({
|
|
164
|
+
cwd: tmpDir,
|
|
165
|
+
check: true,
|
|
166
|
+
quiet: true
|
|
167
|
+
});
|
|
168
|
+
(0, import_vitest.expect)(ok).toBe(false);
|
|
169
|
+
(0, import_vitest.expect)(results.every(r => r.action === "would-overwrite")).toBe(true);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
(0, import_vitest.describe)("--eject mode", () => {
|
|
173
|
+
(0, import_vitest.it)("writes files WITHOUT the @one/generated marker", () => {
|
|
174
|
+
const {
|
|
175
|
+
results
|
|
176
|
+
} = (0, import_generateBundlerConfig.generateBundlerConfig)({
|
|
177
|
+
cwd: tmpDir,
|
|
178
|
+
eject: true,
|
|
179
|
+
quiet: true
|
|
180
|
+
});
|
|
181
|
+
(0, import_vitest.expect)(results.map(r => r.action)).toEqual(["wrote", "wrote"]);
|
|
182
|
+
const babel = import_node_fs.default.readFileSync(import_node_path.default.join(tmpDir, "babel.config.cjs"), "utf8");
|
|
183
|
+
(0, import_vitest.expect)(babel).not.toContain(import_generateBundlerConfig.ONE_GENERATED_MARKER);
|
|
184
|
+
(0, import_vitest.expect)(babel).toContain("you own this file");
|
|
185
|
+
(0, import_vitest.expect)(babel).toContain("require('one/babel-preset')");
|
|
186
|
+
const metro = import_node_fs.default.readFileSync(import_node_path.default.join(tmpDir, "metro.config.cjs"), "utf8");
|
|
187
|
+
(0, import_vitest.expect)(metro).not.toContain(import_generateBundlerConfig.ONE_GENERATED_MARKER);
|
|
188
|
+
(0, import_vitest.expect)(metro).toContain("withOne");
|
|
189
|
+
});
|
|
190
|
+
(0, import_vitest.it)("subsequent auto-gen run (no --eject) treats ejected files as customized", () => {
|
|
191
|
+
(0, import_generateBundlerConfig.generateBundlerConfig)({
|
|
192
|
+
cwd: tmpDir,
|
|
193
|
+
eject: true,
|
|
194
|
+
quiet: true
|
|
195
|
+
});
|
|
196
|
+
const before = import_node_fs.default.readFileSync(import_node_path.default.join(tmpDir, "babel.config.cjs"), "utf8");
|
|
197
|
+
const {
|
|
198
|
+
results
|
|
199
|
+
} = (0, import_generateBundlerConfig.generateBundlerConfig)({
|
|
200
|
+
cwd: tmpDir,
|
|
201
|
+
quiet: true
|
|
202
|
+
});
|
|
203
|
+
(0, import_vitest.expect)(results.every(r => r.action === "skipped-customized")).toBe(true);
|
|
204
|
+
const after = import_node_fs.default.readFileSync(import_node_path.default.join(tmpDir, "babel.config.cjs"), "utf8");
|
|
205
|
+
(0, import_vitest.expect)(after).toBe(before);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
(0, import_vitest.it)("does not clobber a non-.cjs config in the same family", () => {
|
|
209
|
+
import_node_fs.default.writeFileSync(import_node_path.default.join(tmpDir, "babel.config.js"), "module.exports = { presets: [] }\n");
|
|
210
|
+
const {
|
|
211
|
+
results
|
|
212
|
+
} = (0, import_generateBundlerConfig.generateBundlerConfig)({
|
|
213
|
+
cwd: tmpDir,
|
|
214
|
+
quiet: true
|
|
215
|
+
});
|
|
216
|
+
const babelResult = results.find(r => r.filePath.endsWith("babel.config.js") || r.filePath.endsWith("babel.config.cjs"));
|
|
217
|
+
(0, import_vitest.expect)(babelResult.action).toBe("skipped-other-format");
|
|
218
|
+
(0, import_vitest.expect)(import_node_fs.default.existsSync(import_node_path.default.join(tmpDir, "babel.config.cjs"))).toBe(false);
|
|
219
|
+
});
|
|
220
|
+
(0, import_vitest.it)("embeds loaded One router/setup options into both config files", () => {
|
|
221
|
+
(0, import_generateBundlerConfig.generateBundlerConfig)({
|
|
222
|
+
cwd: tmpDir,
|
|
223
|
+
quiet: true,
|
|
224
|
+
oneOptions: {
|
|
225
|
+
router: {
|
|
226
|
+
root: "src/routes",
|
|
227
|
+
ignoredRouteFiles: ["**/*.native-test.*"],
|
|
228
|
+
linking: {
|
|
229
|
+
scheme: "myapp",
|
|
230
|
+
prefixes: ["https://example.com/app"]
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
setupFile: {
|
|
234
|
+
native: "src/setup.native.ts"
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
const babel = import_node_fs.default.readFileSync(import_node_path.default.join(tmpDir, "babel.config.cjs"), "utf8");
|
|
239
|
+
const metro = import_node_fs.default.readFileSync(import_node_path.default.join(tmpDir, "metro.config.cjs"), "utf8");
|
|
240
|
+
for (const file of [babel, metro]) {
|
|
241
|
+
(0, import_vitest.expect)(file).toContain('"routerRoot": "src/routes"');
|
|
242
|
+
(0, import_vitest.expect)(file).toContain('"ignoredRouteFiles"');
|
|
243
|
+
(0, import_vitest.expect)(file).toContain('"**/*.native-test.*"');
|
|
244
|
+
(0, import_vitest.expect)(file).toContain('"scheme": "myapp"');
|
|
245
|
+
(0, import_vitest.expect)(file).toContain('"native": "src/setup.native.ts"');
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
(0, import_vitest.it)("refuses to silently drop non-serializable options", () => {
|
|
249
|
+
(0, import_vitest.expect)(() => (0, import_generateBundlerConfig.generateBundlerConfig)({
|
|
250
|
+
cwd: tmpDir,
|
|
251
|
+
quiet: true,
|
|
252
|
+
oneOptions: {
|
|
253
|
+
router: {
|
|
254
|
+
linking: {
|
|
255
|
+
// the plugin API only accepts serializable router.linking fields
|
|
256
|
+
filter: () => true
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
})).toThrow(/JSON-serializable/);
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
(0, import_vitest.describe)("isCiEnvironment", () => {
|
|
264
|
+
const originalCi = process.env.CI;
|
|
265
|
+
const originalEasBuild = process.env.EAS_BUILD;
|
|
266
|
+
(0, import_vitest.afterEach)(() => {
|
|
267
|
+
if (originalCi === void 0) delete process.env.CI;else process.env.CI = originalCi;
|
|
268
|
+
if (originalEasBuild === void 0) delete process.env.EAS_BUILD;else process.env.EAS_BUILD = originalEasBuild;
|
|
269
|
+
});
|
|
270
|
+
(0, import_vitest.it)("is true when CI=true", () => {
|
|
271
|
+
process.env.CI = "true";
|
|
272
|
+
delete process.env.EAS_BUILD;
|
|
273
|
+
(0, import_vitest.expect)((0, import_generateBundlerConfig.isCiEnvironment)()).toBe(true);
|
|
274
|
+
});
|
|
275
|
+
(0, import_vitest.it)("is true when CI=1", () => {
|
|
276
|
+
process.env.CI = "1";
|
|
277
|
+
delete process.env.EAS_BUILD;
|
|
278
|
+
(0, import_vitest.expect)((0, import_generateBundlerConfig.isCiEnvironment)()).toBe(true);
|
|
279
|
+
});
|
|
280
|
+
(0, import_vitest.it)("is true when EAS_BUILD=true", () => {
|
|
281
|
+
delete process.env.CI;
|
|
282
|
+
process.env.EAS_BUILD = "true";
|
|
283
|
+
(0, import_vitest.expect)((0, import_generateBundlerConfig.isCiEnvironment)()).toBe(true);
|
|
284
|
+
});
|
|
285
|
+
(0, import_vitest.it)("is false when neither is set", () => {
|
|
286
|
+
delete process.env.CI;
|
|
287
|
+
delete process.env.EAS_BUILD;
|
|
288
|
+
(0, import_vitest.expect)((0, import_generateBundlerConfig.isCiEnvironment)()).toBe(false);
|
|
289
|
+
});
|
|
290
|
+
(0, import_vitest.it)("is false when CI=false or CI=0", () => {
|
|
291
|
+
delete process.env.EAS_BUILD;
|
|
292
|
+
process.env.CI = "false";
|
|
293
|
+
(0, import_vitest.expect)((0, import_generateBundlerConfig.isCiEnvironment)()).toBe(false);
|
|
294
|
+
process.env.CI = "0";
|
|
295
|
+
(0, import_vitest.expect)((0, import_generateBundlerConfig.isCiEnvironment)()).toBe(false);
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
(0, import_vitest.describe)("maybeGenerateBundlerConfigOnInstall", () => {
|
|
299
|
+
let tmpDir;
|
|
300
|
+
const originalCi = process.env.CI;
|
|
301
|
+
(0, import_vitest.beforeEach)(() => {
|
|
302
|
+
tmpDir = import_node_fs.default.mkdtempSync(import_node_path.default.join(import_node_os.default.tmpdir(), "one-gen-bundler-ci-test-"));
|
|
303
|
+
});
|
|
304
|
+
(0, import_vitest.afterEach)(() => {
|
|
305
|
+
import_node_fs.default.rmSync(tmpDir, {
|
|
306
|
+
recursive: true,
|
|
307
|
+
force: true
|
|
308
|
+
});
|
|
309
|
+
if (originalCi === void 0) delete process.env.CI;else process.env.CI = originalCi;
|
|
310
|
+
delete process.env.EAS_BUILD;
|
|
311
|
+
});
|
|
312
|
+
(0, import_vitest.it)("does NOT generate files when not in CI even if expo-updates is present", () => {
|
|
313
|
+
delete process.env.CI;
|
|
314
|
+
delete process.env.EAS_BUILD;
|
|
315
|
+
const fakeUpdates = import_node_path.default.join(tmpDir, "node_modules/expo-updates");
|
|
316
|
+
import_node_fs.default.mkdirSync(fakeUpdates, {
|
|
317
|
+
recursive: true
|
|
318
|
+
});
|
|
319
|
+
import_node_fs.default.writeFileSync(import_node_path.default.join(fakeUpdates, "package.json"), JSON.stringify({
|
|
320
|
+
name: "expo-updates"
|
|
321
|
+
}));
|
|
322
|
+
(0, import_generateBundlerConfig.maybeGenerateBundlerConfigOnInstall)(tmpDir);
|
|
323
|
+
(0, import_vitest.expect)(import_node_fs.default.existsSync(import_node_path.default.join(tmpDir, "babel.config.cjs"))).toBe(false);
|
|
324
|
+
(0, import_vitest.expect)(import_node_fs.default.existsSync(import_node_path.default.join(tmpDir, "metro.config.cjs"))).toBe(false);
|
|
325
|
+
});
|
|
326
|
+
(0, import_vitest.it)("does NOT generate files in CI when expo-updates is absent", () => {
|
|
327
|
+
process.env.CI = "true";
|
|
328
|
+
(0, import_generateBundlerConfig.maybeGenerateBundlerConfigOnInstall)(tmpDir);
|
|
329
|
+
(0, import_vitest.expect)(import_node_fs.default.existsSync(import_node_path.default.join(tmpDir, "babel.config.cjs"))).toBe(false);
|
|
330
|
+
(0, import_vitest.expect)(import_node_fs.default.existsSync(import_node_path.default.join(tmpDir, "metro.config.cjs"))).toBe(false);
|
|
331
|
+
});
|
|
332
|
+
(0, import_vitest.it)("generates files in CI when expo-updates is present", () => {
|
|
333
|
+
process.env.CI = "true";
|
|
334
|
+
const fakeUpdates = import_node_path.default.join(tmpDir, "node_modules/expo-updates");
|
|
335
|
+
import_node_fs.default.mkdirSync(fakeUpdates, {
|
|
336
|
+
recursive: true
|
|
337
|
+
});
|
|
338
|
+
import_node_fs.default.writeFileSync(import_node_path.default.join(fakeUpdates, "package.json"), JSON.stringify({
|
|
339
|
+
name: "expo-updates"
|
|
340
|
+
}));
|
|
341
|
+
const consoleInfo = import_vitest.vi.spyOn(console, "info").mockImplementation(() => {});
|
|
342
|
+
try {
|
|
343
|
+
(0, import_generateBundlerConfig.maybeGenerateBundlerConfigOnInstall)(tmpDir);
|
|
344
|
+
} finally {
|
|
345
|
+
consoleInfo.mockRestore();
|
|
346
|
+
}
|
|
347
|
+
(0, import_vitest.expect)(import_node_fs.default.existsSync(import_node_path.default.join(tmpDir, "babel.config.cjs"))).toBe(true);
|
|
348
|
+
(0, import_vitest.expect)(import_node_fs.default.existsSync(import_node_path.default.join(tmpDir, "metro.config.cjs"))).toBe(true);
|
|
349
|
+
});
|
|
350
|
+
});
|