patch-project 0.0.1 → 0.0.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.
- package/LICENSE +22 -0
- package/README.md +25 -0
- package/app.plugin.js +1 -0
- package/build/cli/dir.d.ts +4 -0
- package/build/cli/dir.js +15 -0
- package/build/cli/dir.js.map +1 -0
- package/build/cli/generateNativeProjects.d.ts +23 -0
- package/build/cli/generateNativeProjects.js +75 -0
- package/build/cli/generateNativeProjects.js.map +1 -0
- package/build/cli/index.d.ts +2 -0
- package/build/cli/index.js +102 -0
- package/build/cli/index.js.map +1 -0
- package/build/cli/logger.d.ts +16 -0
- package/build/cli/logger.js +56 -0
- package/build/cli/logger.js.map +1 -0
- package/build/cli/normalizeNativeProjects.d.ts +18 -0
- package/build/cli/normalizeNativeProjects.js +94 -0
- package/build/cli/normalizeNativeProjects.js.map +1 -0
- package/build/cli/patchProjectAsync.d.ts +16 -0
- package/build/cli/patchProjectAsync.js +134 -0
- package/build/cli/patchProjectAsync.js.map +1 -0
- package/build/cli/resolveFromExpoCli.d.ts +4 -0
- package/build/cli/resolveFromExpoCli.js +21 -0
- package/build/cli/resolveFromExpoCli.js.map +1 -0
- package/build/cli/workingDirectories.d.ts +18 -0
- package/build/cli/workingDirectories.js +34 -0
- package/build/cli/workingDirectories.js.map +1 -0
- package/build/env.d.ts +1 -0
- package/build/env.js +6 -0
- package/build/env.js.map +1 -0
- package/build/gitPatch.d.ts +6 -0
- package/build/gitPatch.js +110 -0
- package/build/gitPatch.js.map +1 -0
- package/build/withPatchPlugin.d.ts +9 -0
- package/build/withPatchPlugin.js +104 -0
- package/build/withPatchPlugin.js.map +1 -0
- package/package.json +56 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-present 650 Industries, Inc. (aka Expo)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# patch-project
|
|
2
|
+
|
|
3
|
+
An Expo config-plugin and tool to support patch-based CNG.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
First, install the package:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
$ npx expo install patch-project
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Generate patches
|
|
14
|
+
|
|
15
|
+
After manually modifying files inside the **android** or **ios** directories, you can run the following command to generate the patches:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
$ npx patch-project
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The patches will be generated in the **cng-patches** directory. Whenever you run `npx expo prebuild`, these patches will be applied.
|
|
22
|
+
|
|
23
|
+
### Advanced usage
|
|
24
|
+
|
|
25
|
+
The tool also supports more advanced usage, such as converting a bare project back to a managed project. Run `npx patch-project` for more details.
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./build/withPatchPlugin');
|
package/build/cli/dir.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.moveAsync = exports.ensureDirectoryAsync = exports.directoryExistsAsync = void 0;
|
|
7
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
+
async function directoryExistsAsync(file) {
|
|
9
|
+
return (await fs_extra_1.default.promises.stat(file).catch(() => null))?.isDirectory() ?? false;
|
|
10
|
+
}
|
|
11
|
+
exports.directoryExistsAsync = directoryExistsAsync;
|
|
12
|
+
const ensureDirectoryAsync = (path) => fs_extra_1.default.promises.mkdir(path, { recursive: true });
|
|
13
|
+
exports.ensureDirectoryAsync = ensureDirectoryAsync;
|
|
14
|
+
exports.moveAsync = fs_extra_1.default.move;
|
|
15
|
+
//# sourceMappingURL=dir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dir.js","sourceRoot":"","sources":["../../src/cli/dir.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA0B;AAEnB,KAAK,UAAU,oBAAoB,CAAC,IAAY;IACrD,OAAO,CAAC,MAAM,kBAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,KAAK,CAAC;AAClF,CAAC;AAFD,oDAEC;AAEM,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,kBAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAAtF,QAAA,oBAAoB,wBAAkE;AAEtF,QAAA,SAAS,GAAG,kBAAE,CAAC,IAAI,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ExpoConfig } from '@expo/config';
|
|
2
|
+
import { type ModPlatform } from '@expo/config-plugins';
|
|
3
|
+
/**
|
|
4
|
+
* Generates native projects for the given platforms.
|
|
5
|
+
* This step is similar to the `expo prebuild` command but removes some validation.
|
|
6
|
+
* @return The checksum of the template used to generate the native projects.
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateNativeProjectsAsync(projectRoot: string, exp: ExpoConfig, options: {
|
|
9
|
+
/** List of platforms to prebuild. */
|
|
10
|
+
platforms: ModPlatform[];
|
|
11
|
+
/** URL or file path to the prebuild template. */
|
|
12
|
+
template?: string;
|
|
13
|
+
/** Directory to write the template to before copying into the project. */
|
|
14
|
+
templateDirectory: string;
|
|
15
|
+
}): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Sanity check for the native project before attempting to run patch-project.
|
|
18
|
+
*/
|
|
19
|
+
export declare function platformSanityCheckAsync({ exp, projectRoot, platform, }: {
|
|
20
|
+
exp: ExpoConfig;
|
|
21
|
+
projectRoot: string;
|
|
22
|
+
platform: ModPlatform;
|
|
23
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.platformSanityCheckAsync = exports.generateNativeProjectsAsync = void 0;
|
|
7
|
+
const spawn_async_1 = __importDefault(require("@expo/spawn-async"));
|
|
8
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const dir_1 = require("./dir");
|
|
11
|
+
const resolveFromExpoCli_1 = require("./resolveFromExpoCli");
|
|
12
|
+
/**
|
|
13
|
+
* Generates native projects for the given platforms.
|
|
14
|
+
* This step is similar to the `expo prebuild` command but removes some validation.
|
|
15
|
+
* @return The checksum of the template used to generate the native projects.
|
|
16
|
+
*/
|
|
17
|
+
async function generateNativeProjectsAsync(projectRoot, exp, options) {
|
|
18
|
+
const { configureProjectAsync } = require((0, resolveFromExpoCli_1.resolveFromExpoCli)(projectRoot, 'build/src/prebuild/configureProjectAsync'));
|
|
19
|
+
const { resolveTemplateOption } = require((0, resolveFromExpoCli_1.resolveFromExpoCli)(projectRoot, 'build/src/prebuild/resolveOptions'));
|
|
20
|
+
const { cloneTemplateAndCopyToProjectAsync } = require((0, resolveFromExpoCli_1.resolveFromExpoCli)(projectRoot, 'build/src/prebuild/updateFromTemplate'));
|
|
21
|
+
// Create native projects from template.
|
|
22
|
+
const { templateChecksum } = await cloneTemplateAndCopyToProjectAsync({
|
|
23
|
+
exp,
|
|
24
|
+
projectRoot,
|
|
25
|
+
template: options.template != null ? resolveTemplateOption(options.template) : undefined,
|
|
26
|
+
templateDirectory: options.templateDirectory,
|
|
27
|
+
platforms: options.platforms,
|
|
28
|
+
});
|
|
29
|
+
// Apply config-plugins to native projects.
|
|
30
|
+
await configureProjectAsync(projectRoot, {
|
|
31
|
+
platforms: options.platforms,
|
|
32
|
+
exp,
|
|
33
|
+
});
|
|
34
|
+
// Install CocoaPods is a must on ios because some changes are happening in the `pod install` stage.
|
|
35
|
+
// That would minimize the diff between the native projects.
|
|
36
|
+
if (options.platforms.includes('ios')) {
|
|
37
|
+
const { installCocoaPodsAsync } = require((0, resolveFromExpoCli_1.resolveFromExpoCli)(projectRoot, 'build/src/utils/cocoapods'));
|
|
38
|
+
await installCocoaPodsAsync(projectRoot);
|
|
39
|
+
}
|
|
40
|
+
return templateChecksum;
|
|
41
|
+
}
|
|
42
|
+
exports.generateNativeProjectsAsync = generateNativeProjectsAsync;
|
|
43
|
+
/**
|
|
44
|
+
* Sanity check for the native project before attempting to run patch-project.
|
|
45
|
+
*/
|
|
46
|
+
async function platformSanityCheckAsync({ exp, projectRoot, platform, }) {
|
|
47
|
+
// Check platform directory exists and is not empty.
|
|
48
|
+
const platformDir = path_1.default.join(projectRoot, platform);
|
|
49
|
+
if (!(await (0, dir_1.directoryExistsAsync)(platformDir))) {
|
|
50
|
+
throw new Error(`Platform directory does not exist: ${platformDir}`);
|
|
51
|
+
}
|
|
52
|
+
const files = await promises_1.default.readdir(platformDir);
|
|
53
|
+
if (files.length === 0) {
|
|
54
|
+
throw new Error(`Platform directory is empty: ${platformDir}`);
|
|
55
|
+
}
|
|
56
|
+
// Check package and bundle identifier are defined.
|
|
57
|
+
if (platform === 'android' && !exp.android?.package) {
|
|
58
|
+
throw new Error(`android.package is not defined in your app config. Please define it before running this command.`);
|
|
59
|
+
}
|
|
60
|
+
if (platform === 'ios' && !exp.ios?.bundleIdentifier) {
|
|
61
|
+
throw new Error(`ios.bundleIdentifier is not defined in your app config. Please define it before running this command.`);
|
|
62
|
+
}
|
|
63
|
+
// Check if git is installed.
|
|
64
|
+
try {
|
|
65
|
+
await (0, spawn_async_1.default)('git', ['--version'], { stdio: 'ignore' });
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
if (e.code === 'ENOENT') {
|
|
69
|
+
e.message += `\nGit is required to run this command. Install Git and try again.`;
|
|
70
|
+
}
|
|
71
|
+
throw e;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.platformSanityCheckAsync = platformSanityCheckAsync;
|
|
75
|
+
//# sourceMappingURL=generateNativeProjects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateNativeProjects.js","sourceRoot":"","sources":["../../src/cli/generateNativeProjects.ts"],"names":[],"mappings":";;;;;;AAEA,oE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function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
const arg_1 = __importDefault(require("arg"));
|
|
31
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
32
|
+
const fs_1 = require("fs");
|
|
33
|
+
const path_1 = __importDefault(require("path"));
|
|
34
|
+
const logger = __importStar(require("./logger"));
|
|
35
|
+
const patchProjectAsync_1 = require("./patchProjectAsync");
|
|
36
|
+
(async () => {
|
|
37
|
+
const args = (0, arg_1.default)({
|
|
38
|
+
// Types
|
|
39
|
+
'--help': Boolean,
|
|
40
|
+
'--clean': Boolean,
|
|
41
|
+
'--template': String,
|
|
42
|
+
'--platform': String,
|
|
43
|
+
// Aliases
|
|
44
|
+
'-h': '--help',
|
|
45
|
+
'-p': '--platform',
|
|
46
|
+
});
|
|
47
|
+
if (args['--help']) {
|
|
48
|
+
printHelp(`(Experimental) Generate patch files for iOS and Android native projects to persist changes made manually after prebuild`, (0, chalk_1.default) `npx patch-project {dim <dir>}`, [
|
|
49
|
+
(0, chalk_1.default) `<dir> Directory of the Expo project. {dim Default: Current working directory}`,
|
|
50
|
+
`--clean Delete the native folders after the conversion`,
|
|
51
|
+
`--template <template> Project template to clone from. File path pointing to a local tar file or a github repo`,
|
|
52
|
+
(0, chalk_1.default) `-p, --platform <all|android|ios> Platforms to sync: ios, android, all. {dim Default: all}`,
|
|
53
|
+
`-h, --help Usage info`,
|
|
54
|
+
].join('\n'));
|
|
55
|
+
}
|
|
56
|
+
const projectRoot = path_1.default.resolve(args._[0] || '.');
|
|
57
|
+
if (!(0, fs_1.existsSync)(projectRoot)) {
|
|
58
|
+
logger.exit(`Invalid project root: ${projectRoot}`);
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
await (0, patchProjectAsync_1.patchProjectAsync)(projectRoot, {
|
|
62
|
+
// Parsed options
|
|
63
|
+
clean: !!args['--clean'],
|
|
64
|
+
platforms: resolvePlatformOption(args['--platform']),
|
|
65
|
+
template: args['--template'],
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
if (e instanceof Error || typeof e === 'string') {
|
|
70
|
+
logger.exit(e);
|
|
71
|
+
}
|
|
72
|
+
throw e;
|
|
73
|
+
}
|
|
74
|
+
})();
|
|
75
|
+
// Install exit hooks
|
|
76
|
+
process.on('SIGINT', () => process.exit(0));
|
|
77
|
+
process.on('SIGTERM', () => process.exit(0));
|
|
78
|
+
function printHelp(info, usage, options, extra = '') {
|
|
79
|
+
logger.exit((0, chalk_1.default) `
|
|
80
|
+
{bold Info}
|
|
81
|
+
${info}
|
|
82
|
+
|
|
83
|
+
{bold Usage}
|
|
84
|
+
{dim $} ${usage}
|
|
85
|
+
|
|
86
|
+
{bold Options}
|
|
87
|
+
${options.split('\n').join('\n ')}
|
|
88
|
+
` + extra, 0);
|
|
89
|
+
}
|
|
90
|
+
function resolvePlatformOption(platform = 'all', { loose } = {}) {
|
|
91
|
+
switch (platform) {
|
|
92
|
+
case 'ios':
|
|
93
|
+
return ['ios'];
|
|
94
|
+
case 'android':
|
|
95
|
+
return ['android'];
|
|
96
|
+
case 'all':
|
|
97
|
+
return loose || process.platform !== 'win32' ? ['android', 'ios'] : ['android'];
|
|
98
|
+
default:
|
|
99
|
+
return [platform];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,8CAAsB;AACtB,kDAA0B;AAE1B,2BAAgC;AAChC,gDAAwB;AAExB,iDAAmC;AACnC,2DAAwD;AAExD,CAAC,KAAK,IAAI,EAAE;IACV,MAAM,IAAI,GAAG,IAAA,aAAG,EAAC;QACf,QAAQ;QACR,QAAQ,EAAE,OAAO;QACjB,SAAS,EAAE,OAAO;QAClB,YAAY,EAAE,MAAM;QACpB,YAAY,EAAE,MAAM;QACpB,UAAU;QACV,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,YAAY;KACnB,CAAC,CAAC;IAEH,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE;QAClB,SAAS,CACP,yHAAyH,EACzH,IAAA,eAAK,EAAA,+BAA+B,EACpC;YACE,IAAA,eAAK,EAAA,kHAAkH;YACvH,yFAAyF;YACzF,kIAAkI;YAClI,IAAA,eAAK,EAAA,mGAAmG;YACxG,qDAAqD;SACtD,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;KACH;IAED,MAAM,WAAW,GAAG,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K,KAA0B,EAAE;IAEnC,QAAQ,QAAQ,EAAE;QAChB,KAAK,KAAK;YACR,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,KAAK,SAAS;YACZ,OAAO,CAAC,SAAS,CAAC,CAAC;QACrB,KAAK,KAAK;YACR,OAAO,KAAK,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAClF;YACE,OAAO,CAAC,QAAuB,CAAC,CAAC;KACpC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const log: {
|
|
2
|
+
(...data: any[]): void;
|
|
3
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
4
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
5
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
6
|
+
};
|
|
7
|
+
export declare const error: {
|
|
8
|
+
(...data: any[]): void;
|
|
9
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
10
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
11
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
12
|
+
};
|
|
13
|
+
/** Print an error and provide additional info (the stack trace) in debug mode. */
|
|
14
|
+
export declare function exception(e: Error): void;
|
|
15
|
+
/** Log a message and exit the current process. If the `code` is non-zero then `console.error` will be used instead of `console.log`. */
|
|
16
|
+
export declare function exit(message: string | Error, code?: number): never;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.exit = exports.exception = exports.error = exports.log = void 0;
|
|
30
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
31
|
+
const env = __importStar(require("../env"));
|
|
32
|
+
exports.log = console.log;
|
|
33
|
+
exports.error = console.error;
|
|
34
|
+
/** Print an error and provide additional info (the stack trace) in debug mode. */
|
|
35
|
+
function exception(e) {
|
|
36
|
+
(0, exports.error)(chalk_1.default.red(e.toString()) + (env.EXPO_DEBUG ? '\n' + chalk_1.default.gray(e.stack) : ''));
|
|
37
|
+
}
|
|
38
|
+
exports.exception = exception;
|
|
39
|
+
/** Log a message and exit the current process. If the `code` is non-zero then `console.error` will be used instead of `console.log`. */
|
|
40
|
+
function exit(message, code = 1) {
|
|
41
|
+
if (message instanceof Error) {
|
|
42
|
+
exception(message);
|
|
43
|
+
process.exit(code);
|
|
44
|
+
}
|
|
45
|
+
if (message) {
|
|
46
|
+
if (code === 0) {
|
|
47
|
+
(0, exports.log)(message);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
(0, exports.error)(message);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
process.exit(code);
|
|
54
|
+
}
|
|
55
|
+
exports.exit = exit;
|
|
56
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/cli/logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAE1B,4CAA8B;AAEjB,QAAA,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;AAClB,QAAA,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AAEnC,kFAAkF;AAClF,SAAgB,SAAS,CAAC,CAAQ;IAChC,IAAA,aAAK,EAAC,eAAK,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,GAAG,eAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACtF,CAAC;AAFD,8BAEC;AAED,wIAAwI;AACxI,SAAgB,IAAI,CAAC,OAAuB,EAAE,OAAe,CAAC;IAC5D,IAAI,OAAO,YAAY,KAAK,EAAE;QAC5B,SAAS,CAAC,OAAO,CAAC,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACpB;IAED,IAAI,OAAO,EAAE;QACX,IAAI,IAAI,KAAK,CAAC,EAAE;YACd,IAAA,WAAG,EAAC,OAAO,CAAC,CAAC;SACd;aAAM;YACL,IAAA,aAAK,EAAC,OAAO,CAAC,CAAC;SAChB;KACF;IAED,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrB,CAAC;AAfD,oBAeC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ModPlatform } from '@expo/config-plugins';
|
|
2
|
+
import type { WorkingDirectories } from './workingDirectories';
|
|
3
|
+
interface Params {
|
|
4
|
+
projectRoot: string;
|
|
5
|
+
workingDirectories: WorkingDirectories;
|
|
6
|
+
platform: ModPlatform;
|
|
7
|
+
backup: boolean;
|
|
8
|
+
}
|
|
9
|
+
type BackupFileMappings = Record<string, string>;
|
|
10
|
+
/**
|
|
11
|
+
* Normalize the native projects to minimize the diff between prebuilds.
|
|
12
|
+
*/
|
|
13
|
+
export declare function normalizeNativeProjectsAsync(params: Params): Promise<BackupFileMappings>;
|
|
14
|
+
/**
|
|
15
|
+
* Revert the changes made by `normalizeNativeProjectsAsync()`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function revertNormalizeNativeProjectsAsync(backupFileMappings: BackupFileMappings): Promise<void>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.revertNormalizeNativeProjectsAsync = exports.normalizeNativeProjectsAsync = void 0;
|
|
7
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
8
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
/**
|
|
11
|
+
* Normalize the native projects to minimize the diff between prebuilds.
|
|
12
|
+
*/
|
|
13
|
+
async function normalizeNativeProjectsAsync(params) {
|
|
14
|
+
if (params.platform === 'ios') {
|
|
15
|
+
return await normalizeIosProjectsAsync(params);
|
|
16
|
+
}
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
exports.normalizeNativeProjectsAsync = normalizeNativeProjectsAsync;
|
|
20
|
+
/**
|
|
21
|
+
* Revert the changes made by `normalizeNativeProjectsAsync()`.
|
|
22
|
+
*/
|
|
23
|
+
async function revertNormalizeNativeProjectsAsync(backupFileMappings) {
|
|
24
|
+
await Promise.all(Object.entries(backupFileMappings).map(([originalPath, backupPath]) => promises_1.default.copyFile(backupPath, originalPath)));
|
|
25
|
+
}
|
|
26
|
+
exports.revertNormalizeNativeProjectsAsync = revertNormalizeNativeProjectsAsync;
|
|
27
|
+
/**
|
|
28
|
+
* `normalizeNativeProjectsAsync()` implementation for iOS.
|
|
29
|
+
*/
|
|
30
|
+
async function normalizeIosProjectsAsync({ projectRoot, workingDirectories, backup, }) {
|
|
31
|
+
const backupFileMappings = {};
|
|
32
|
+
// Normalize the pbxproj file since it has some dynamic IDs that change between prebuilds.
|
|
33
|
+
const xcodeProjectPath = config_plugins_1.IOSConfig.Paths.getPBXProjectPath(projectRoot);
|
|
34
|
+
const xcodeProjectPathBackup = path_1.default.join(workingDirectories.tmpDir, path_1.default.basename(xcodeProjectPath));
|
|
35
|
+
if (backup) {
|
|
36
|
+
await promises_1.default.copyFile(xcodeProjectPath, xcodeProjectPathBackup);
|
|
37
|
+
backupFileMappings[xcodeProjectPath] = xcodeProjectPathBackup;
|
|
38
|
+
}
|
|
39
|
+
await normalizeXcodeProjectAsync(projectRoot, xcodeProjectPath);
|
|
40
|
+
return backupFileMappings;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Normalize the Xcode project file by removing some dynamic values.
|
|
44
|
+
* - Remove the `noop-file.swift` file that is generated by the prebuild process.
|
|
45
|
+
* - Remove the Swift bridging header file that is generated by the prebuild process.
|
|
46
|
+
* - Remove the `ExpoModulesProvider.swift` that is generated by expo-modules-autolinking and `pod install`.
|
|
47
|
+
* - Remove the `[Expo] Configure project` build phase that is generated by expo-modules-autolinking and `pod install`.
|
|
48
|
+
* - Remove the CocoaPods build phases that are generated by `pod install`.
|
|
49
|
+
*/
|
|
50
|
+
async function normalizeXcodeProjectAsync(projectRoot, xcodeProjectPath) {
|
|
51
|
+
const projectName = config_plugins_1.IOSConfig.XcodeUtils.getProjectName(projectRoot);
|
|
52
|
+
const project = config_plugins_1.IOSConfig.XcodeUtils.getPbxproj(projectRoot);
|
|
53
|
+
const mainAppGroup = findXcodeProjectMainAppGroupKey(project, projectName);
|
|
54
|
+
project.removeSourceFile('noop-file.swift', null, mainAppGroup);
|
|
55
|
+
project.removeSourceFile('ExpoModulesProvider.swift', null, mainAppGroup);
|
|
56
|
+
project.removeSourceFile(`${projectName}-Bridging-Header.h`, null, mainAppGroup);
|
|
57
|
+
removeXcodeProjectBuildPhase(project, '[Expo] Configure project');
|
|
58
|
+
removeXcodeProjectBuildPhase(project, '[CP] Embed Pods Frameworks');
|
|
59
|
+
removeXcodeProjectBuildPhase(project, '[CP] Check Pods Manifest.lock');
|
|
60
|
+
removeXcodeProjectBuildPhase(project, '[CP] Copy Pods Resources');
|
|
61
|
+
await promises_1.default.writeFile(xcodeProjectPath, project.writeSync(), 'utf8');
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Find the main app group key in the Xcode project.
|
|
65
|
+
*/
|
|
66
|
+
function findXcodeProjectMainAppGroupKey(project, projectName) {
|
|
67
|
+
const targetGroupKey = project.findPBXGroupKey({ name: projectName });
|
|
68
|
+
// Sanity check
|
|
69
|
+
const { firstProject } = project.getFirstProject();
|
|
70
|
+
const mainGroup = project.getPBXGroupByKey(firstProject.mainGroup);
|
|
71
|
+
// @ts-expect-error
|
|
72
|
+
const targetGroupKey2 = mainGroup?.children.find(({ comment }) => comment === projectName)?.value;
|
|
73
|
+
if (!targetGroupKey || targetGroupKey !== targetGroupKey2) {
|
|
74
|
+
throw new Error('Unable to find the main app group key');
|
|
75
|
+
}
|
|
76
|
+
return targetGroupKey;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Remove a shell script build phase from the Xcode project.
|
|
80
|
+
*/
|
|
81
|
+
function removeXcodeProjectBuildPhase(project, name) {
|
|
82
|
+
const [, nativeTarget] = config_plugins_1.IOSConfig.Target.findFirstNativeTarget(project);
|
|
83
|
+
// @ts-expect-error
|
|
84
|
+
const index = nativeTarget.buildPhases.findIndex((item) => item.comment === name);
|
|
85
|
+
if (index < 0) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const buildPhaseId = nativeTarget.buildPhases[index].value;
|
|
89
|
+
nativeTarget.buildPhases.splice(index, 1);
|
|
90
|
+
const buildPhases = project.getPBXObject('PBXShellScriptBuildPhase');
|
|
91
|
+
delete buildPhases[buildPhaseId];
|
|
92
|
+
delete buildPhases[`${buildPhaseId}_comment`];
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=normalizeNativeProjects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeNativeProjects.js","sourceRoot":"","sources":["../../src/cli/normalizeNativeProjects.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAsF;AACtF,2DAA6B;AAC7B,gDAAwB;AAaxB;;GAEG;AACI,KAAK,UAAU,4BAA4B,CAAC,MAAc;IAC/D,IAAI,MAAM,CAAC,QAAQ,KAAK,KAAK,EAAE;QAC7B,OAAO,MAAM,yBAAyB,CAAC,MAAM,CAAC,CAAC;KAChD;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AALD,oEAKC;AAED;;GAEG;AACI,KAAK,UAAU,kCAAkC,CACtD,kBAAsC;IAEtC,MAAM,OAAO,CAAC,GAAG,CACf,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,EAAE,EAAE,CACpE,kBAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC,CACtC,CACF,CAAC;AACJ,CAAC;AARD,gFAQC;AAED;;GAEG;AACH,KAAK,UAAU,yBAAyB,CAAC,EACvC,WAAW,EACX,kBAAkB,EAClB,MAAM,GACC;IACP,MAAM,kBAAkB,GAAuB,EAAE,CAAC;IAElD,0FAA0F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1C,MAAM,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,0BAA0B,CAAwB,CAAC;IAC5F,OAAO,WAAW,CAAC,YAAY,CAAC,CAAC;IACjC,OAAO,WAAW,CAAC,GAAG,YAAY,UAAU,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ModPlatform } from '@expo/config-plugins';
|
|
2
|
+
/**
|
|
3
|
+
* Entry point into the patch-project process.
|
|
4
|
+
*/
|
|
5
|
+
export declare function patchProjectAsync(projectRoot: string, options: {
|
|
6
|
+
/** List of platforms to prebuild. */
|
|
7
|
+
platforms: ModPlatform[];
|
|
8
|
+
/** Should delete the native folders after attempting to prebuild. @default false */
|
|
9
|
+
clean?: boolean;
|
|
10
|
+
/** URL or file path to the prebuild template. */
|
|
11
|
+
template?: string;
|
|
12
|
+
/** The options to pass to the `git diff` command. */
|
|
13
|
+
diffOptions?: string[];
|
|
14
|
+
/** The directory to save the patch files. @default `cng-patches` */
|
|
15
|
+
patchRoot?: string;
|
|
16
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.patchProjectAsync = void 0;
|
|
30
|
+
const config_1 = require("@expo/config");
|
|
31
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
32
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
33
|
+
const glob_1 = __importDefault(require("glob"));
|
|
34
|
+
const path_1 = __importDefault(require("path"));
|
|
35
|
+
const util_1 = require("util");
|
|
36
|
+
const dir_1 = require("./dir");
|
|
37
|
+
const generateNativeProjects_1 = require("./generateNativeProjects");
|
|
38
|
+
const logger = __importStar(require("./logger"));
|
|
39
|
+
const normalizeNativeProjects_1 = require("./normalizeNativeProjects");
|
|
40
|
+
const resolveFromExpoCli_1 = require("./resolveFromExpoCli");
|
|
41
|
+
const workingDirectories_1 = require("./workingDirectories");
|
|
42
|
+
const gitPatch_1 = require("../gitPatch");
|
|
43
|
+
const debug = require('debug')('patch-project');
|
|
44
|
+
const globAsync = (0, util_1.promisify)(glob_1.default);
|
|
45
|
+
/**
|
|
46
|
+
* Entry point into the patch-project process.
|
|
47
|
+
*/
|
|
48
|
+
async function patchProjectAsync(projectRoot, options) {
|
|
49
|
+
const { ensureValidPlatforms } = require((0, resolveFromExpoCli_1.resolveFromExpoCli)(projectRoot, 'build/src/prebuild/resolveOptions'));
|
|
50
|
+
const { setNodeEnv } = require((0, resolveFromExpoCli_1.resolveFromExpoCli)(projectRoot, 'build/src/utils/nodeEnv'));
|
|
51
|
+
setNodeEnv('development');
|
|
52
|
+
require('@expo/env').load(projectRoot);
|
|
53
|
+
const { exp } = await (0, config_1.getConfig)(projectRoot);
|
|
54
|
+
const patchRoot = options.patchRoot || 'cng-patches';
|
|
55
|
+
// Warn if the project is attempting to prebuild an unsupported platform (iOS on Windows).
|
|
56
|
+
options.platforms = ensureValidPlatforms(options.platforms);
|
|
57
|
+
for (const platform of options.platforms) {
|
|
58
|
+
await (0, generateNativeProjects_1.platformSanityCheckAsync)({ exp, projectRoot, platform });
|
|
59
|
+
const workingDirectories = await (0, workingDirectories_1.createWorkingDirectoriesAsync)(projectRoot, platform);
|
|
60
|
+
try {
|
|
61
|
+
await removePatchFilesAsync(patchRoot, platform);
|
|
62
|
+
await promises_1.default.mkdir(path_1.default.join(projectRoot, patchRoot), { recursive: true });
|
|
63
|
+
await patchProjectForPlatformAsync({
|
|
64
|
+
projectRoot,
|
|
65
|
+
platform,
|
|
66
|
+
workingDirectories,
|
|
67
|
+
patchRoot,
|
|
68
|
+
exp,
|
|
69
|
+
options,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
await promises_1.default.rm(workingDirectories.rootDir, { recursive: true, force: true });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.patchProjectAsync = patchProjectAsync;
|
|
78
|
+
async function patchProjectForPlatformAsync({ projectRoot, platform, workingDirectories, patchRoot, exp, options, }) {
|
|
79
|
+
const { diffDir, originDir } = workingDirectories;
|
|
80
|
+
debug(`Normalizing native project files for original project`);
|
|
81
|
+
const backupFileMappings = await (0, normalizeNativeProjects_1.normalizeNativeProjectsAsync)({
|
|
82
|
+
projectRoot,
|
|
83
|
+
platform,
|
|
84
|
+
workingDirectories,
|
|
85
|
+
backup: true,
|
|
86
|
+
});
|
|
87
|
+
debug(`Moving native projects to origin directory - originDir[${originDir}]`);
|
|
88
|
+
await promises_1.default.rename(path_1.default.join(projectRoot, platform), originDir);
|
|
89
|
+
debug(`Generating native projects from prebuild template - projectRoot[${projectRoot}]`);
|
|
90
|
+
logger.log(chalk_1.default.bold(`Generating native projects from prebuild template - platform[${platform}]`));
|
|
91
|
+
const templateChecksum = await (0, generateNativeProjects_1.generateNativeProjectsAsync)(projectRoot, exp, {
|
|
92
|
+
platforms: [platform],
|
|
93
|
+
template: options.template,
|
|
94
|
+
templateDirectory: workingDirectories.templateDir,
|
|
95
|
+
});
|
|
96
|
+
debug(`Normalizing native project files for generated project`);
|
|
97
|
+
await (0, normalizeNativeProjects_1.normalizeNativeProjectsAsync)({
|
|
98
|
+
projectRoot,
|
|
99
|
+
platform,
|
|
100
|
+
workingDirectories,
|
|
101
|
+
backup: false,
|
|
102
|
+
});
|
|
103
|
+
debug(`Initializing git repo for diff - diffDir[${diffDir}]`);
|
|
104
|
+
const platformDiffDir = path_1.default.join(diffDir, platform);
|
|
105
|
+
await (0, gitPatch_1.initializeGitRepoAsync)(diffDir);
|
|
106
|
+
await (0, dir_1.moveAsync)(path_1.default.join(projectRoot, platform), platformDiffDir);
|
|
107
|
+
await (0, gitPatch_1.addAllToGitIndexAsync)(diffDir);
|
|
108
|
+
await (0, gitPatch_1.commitAsync)(diffDir, 'Base commit from prebuild template');
|
|
109
|
+
debug(`Moving the original native projects to diff repo`);
|
|
110
|
+
await promises_1.default.rm(platformDiffDir, { recursive: true, force: true });
|
|
111
|
+
await (0, dir_1.moveAsync)(originDir, platformDiffDir);
|
|
112
|
+
debug(`Generating patch file`);
|
|
113
|
+
const patchFilePath = path_1.default.join(projectRoot, patchRoot, `${platform}+${templateChecksum}.patch`);
|
|
114
|
+
logger.log(chalk_1.default.bold(`Saving patch file to ${patchFilePath}`));
|
|
115
|
+
await (0, gitPatch_1.diffAsync)(diffDir, patchFilePath, options.diffOptions ?? []);
|
|
116
|
+
const stat = await promises_1.default.stat(patchFilePath);
|
|
117
|
+
if (stat.size === 0) {
|
|
118
|
+
logger.log(`No changes detected, removing the patch file: ${patchFilePath}`);
|
|
119
|
+
await promises_1.default.rm(patchFilePath);
|
|
120
|
+
}
|
|
121
|
+
if (!options.clean) {
|
|
122
|
+
debug(`Moving the original native projects back to project root`);
|
|
123
|
+
await (0, dir_1.moveAsync)(platformDiffDir, path_1.default.join(projectRoot, platform));
|
|
124
|
+
await (0, normalizeNativeProjects_1.revertNormalizeNativeProjectsAsync)(backupFileMappings);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async function removePatchFilesAsync(patchRoot, platform) {
|
|
128
|
+
const patchFiles = await globAsync(`${platform}*.patch`, { cwd: patchRoot, absolute: true });
|
|
129
|
+
await Promise.all(patchFiles.map((file) => {
|
|
130
|
+
logger.log(`Removing patch file: ${file}`);
|
|
131
|
+
return promises_1.default.rm(file, { force: true });
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=patchProjectAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patchProjectAsync.js","sourceRoot":"","sources":["../../src/cli/patchProjectAsync.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA0D;AAE1D,kDAA0B;AAC1B,2DAA6B;AAC7B,gDAAwB;AACxB,gDAAwB;AACxB,+BAAiC;AAEjC,+BAAkC;AAClC,qEAAiG;AACjG,iDAAmC;AACnC,uEAGmC;AACnC,6DAA0D;AAC1D,6DAA8F;AAC9F,0CAAoG;AAEpG,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,eAAe,CAAuB,CAAC;AACtE,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,cAAI,CAAC,CAAC;AAElC;;GAEG;AACI,KAAK,UAAU,iBAAiB,CACrC,WAAmB,EACnB,OAWC;IAED,MAAM,EAAE,oBAAoB,EAAE,GAAG,OAAO,CACtC,IAAA,uCAAkB,EAAC,WAAW,EA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AAK,UAAU,qBAAqB,CAAC,SAAiB,EAAE,QAAqB;IAC3E,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,GAAG,QAAQ,SAAS,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7F,MAAM,OAAO,CAAC,GAAG,CACf,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACtB,MAAM,CAAC,GAAG,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAC;QAC3C,OAAO,kBAAE,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACtC,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveFromExpoCli = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const resolve_from_1 = __importDefault(require("resolve-from"));
|
|
9
|
+
let cachedCliPath = null;
|
|
10
|
+
/**
|
|
11
|
+
* Resolve a module from the @expo/cli package.
|
|
12
|
+
*/
|
|
13
|
+
function resolveFromExpoCli(projectRoot, moduleId) {
|
|
14
|
+
if (cachedCliPath == null) {
|
|
15
|
+
const expoPackageRoot = path_1.default.dirname((0, resolve_from_1.default)(projectRoot, 'expo/package.json'));
|
|
16
|
+
cachedCliPath = path_1.default.dirname((0, resolve_from_1.default)(expoPackageRoot, '@expo/cli/package.json'));
|
|
17
|
+
}
|
|
18
|
+
return path_1.default.join(cachedCliPath, moduleId);
|
|
19
|
+
}
|
|
20
|
+
exports.resolveFromExpoCli = resolveFromExpoCli;
|
|
21
|
+
//# sourceMappingURL=resolveFromExpoCli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveFromExpoCli.js","sourceRoot":"","sources":["../../src/cli/resolveFromExpoCli.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,gEAAuC;AAEvC,IAAI,aAAa,GAAkB,IAAI,CAAC;AAExC;;GAEG;AACH,SAAgB,kBAAkB,CAAC,WAAmB,EAAE,QAAgB;IACtE,IAAI,aAAa,IAAI,IAAI,EAAE;QACzB,MAAM,eAAe,GAAG,cAAI,CAAC,OAAO,CAAC,IAAA,sBAAW,EAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC,CAAC;QACpF,aAAa,GAAG,cAAI,CAAC,OAAO,CAAC,IAAA,sBAAW,EAAC,eAAe,EAAE,wBAAwB,CAAC,CAAC,CAAC;KACtF;IACD,OAAO,cAAI,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;AAC5C,CAAC;AAND,gDAMC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ModPlatform } from '@expo/config-plugins';
|
|
2
|
+
export interface WorkingDirectories {
|
|
3
|
+
/** Root directory for all the working directories */
|
|
4
|
+
rootDir: string;
|
|
5
|
+
/** Temporary directory to save template files before copying native projects. */
|
|
6
|
+
templateDir: string;
|
|
7
|
+
/** The temporary Git repository to generate diffs. */
|
|
8
|
+
diffDir: string;
|
|
9
|
+
/** The temporary directory to save the original native projects. */
|
|
10
|
+
originDir: string;
|
|
11
|
+
/** The temporary directory to save the misc files. */
|
|
12
|
+
tmpDir: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Create working directories for the patch-project process.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createWorkingDirectoriesAsync(projectRoot: string, platform: ModPlatform): Promise<WorkingDirectories>;
|
|
18
|
+
export declare function ensureAsync(path: string): Promise<string>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ensureAsync = exports.createWorkingDirectoriesAsync = void 0;
|
|
7
|
+
const assert_1 = __importDefault(require("assert"));
|
|
8
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const dir_1 = require("./dir");
|
|
11
|
+
const WORKING_DIR_ROOT = '.patch-project-tmp';
|
|
12
|
+
/**
|
|
13
|
+
* Create working directories for the patch-project process.
|
|
14
|
+
*/
|
|
15
|
+
async function createWorkingDirectoriesAsync(projectRoot, platform) {
|
|
16
|
+
// We put the temporary working directories inside the project root so moving files is fast.
|
|
17
|
+
const rootDir = path_1.default.join(projectRoot, WORKING_DIR_ROOT, platform);
|
|
18
|
+
await promises_1.default.rm(rootDir, { recursive: true, force: true });
|
|
19
|
+
return {
|
|
20
|
+
rootDir: await ensureAsync(rootDir),
|
|
21
|
+
templateDir: await ensureAsync(path_1.default.join(rootDir, 'template')),
|
|
22
|
+
diffDir: await ensureAsync(path_1.default.join(rootDir, 'diff')),
|
|
23
|
+
originDir: await ensureAsync(path_1.default.join(rootDir, 'origin')),
|
|
24
|
+
tmpDir: await ensureAsync(path_1.default.join(rootDir, 'tmp')),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.createWorkingDirectoriesAsync = createWorkingDirectoriesAsync;
|
|
28
|
+
async function ensureAsync(path) {
|
|
29
|
+
const result = await (0, dir_1.ensureDirectoryAsync)(path);
|
|
30
|
+
(0, assert_1.default)(result, 'The return value should be string when recursive is true');
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
exports.ensureAsync = ensureAsync;
|
|
34
|
+
//# sourceMappingURL=workingDirectories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workingDirectories.js","sourceRoot":"","sources":["../../src/cli/workingDirectories.ts"],"names":[],"mappings":";;;;;;AACA,oDAA4B;AAC5B,2DAA6B;AAC7B,gDAAwB;AAExB,+BAA6C;AAE7C,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AAe9C;;GAEG;AACI,KAAK,UAAU,6BAA6B,CACjD,WAAmB,EACnB,QAAqB;IAErB,4FAA4F;IAC5F,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC;IACnE,MAAM,kBAAE,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,OAAO;QACL,OAAO,EAAE,MAAM,WAAW,CAAC,OAAO,CAAC;QACnC,WAAW,EAAE,MAAM,WAAW,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAC9D,OAAO,EAAE,MAAM,WAAW,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACtD,SAAS,EAAE,MAAM,WAAW,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC1D,MAAM,EAAE,MAAM,WAAW,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KACrD,CAAC;AACJ,CAAC;AAdD,sEAcC;AAEM,KAAK,UAAU,WAAW,CAAC,IAAY;IAC5C,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAoB,EAAC,IAAI,CAAC,CAAC;IAChD,IAAA,gBAAM,EAAC,MAAM,EAAE,0DAA0D,CAAC,CAAC;IAC3E,OAAO,MAAM,CAAC;AAChB,CAAC;AAJD,kCAIC"}
|
package/build/env.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EXPO_DEBUG: boolean;
|
package/build/env.js
ADDED
package/build/env.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AAEpB,QAAA,UAAU,GAAG,IAAA,gBAAO,EAAC,YAAY,EAAE,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function initializeGitRepoAsync(repoRoot: string): Promise<void>;
|
|
2
|
+
export declare function addAllToGitIndexAsync(repoRoot: string): Promise<void>;
|
|
3
|
+
export declare function commitAsync(repoRoot: string, message: string): Promise<void>;
|
|
4
|
+
export declare function diffAsync(repoRoot: string, outputPatchFilePath: string, options: string[]): Promise<void>;
|
|
5
|
+
export declare function applyPatchAsync(projectRoot: string, patchFilePath: string): Promise<string>;
|
|
6
|
+
export declare function getPatchChangedLinesAsync(patchFilePath: string): Promise<number>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.getPatchChangedLinesAsync = exports.applyPatchAsync = exports.diffAsync = exports.commitAsync = exports.addAllToGitIndexAsync = exports.initializeGitRepoAsync = void 0;
|
|
30
|
+
const spawn_async_1 = __importDefault(require("@expo/spawn-async"));
|
|
31
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
32
|
+
const path_1 = __importDefault(require("path"));
|
|
33
|
+
const env = __importStar(require("./env"));
|
|
34
|
+
async function initializeGitRepoAsync(repoRoot) {
|
|
35
|
+
try {
|
|
36
|
+
await promises_1.default.rm(path_1.default.join(repoRoot, '.git'), { recursive: true, force: true });
|
|
37
|
+
}
|
|
38
|
+
catch { }
|
|
39
|
+
await runGitAsync(['init'], { cwd: repoRoot });
|
|
40
|
+
await generateDefaultGitignoreAsync(repoRoot);
|
|
41
|
+
}
|
|
42
|
+
exports.initializeGitRepoAsync = initializeGitRepoAsync;
|
|
43
|
+
async function addAllToGitIndexAsync(repoRoot) {
|
|
44
|
+
await runGitAsync(['add', '-A'], { cwd: repoRoot });
|
|
45
|
+
}
|
|
46
|
+
exports.addAllToGitIndexAsync = addAllToGitIndexAsync;
|
|
47
|
+
async function commitAsync(repoRoot, message) {
|
|
48
|
+
await runGitAsync(['commit', '-m', message], {
|
|
49
|
+
cwd: repoRoot,
|
|
50
|
+
env: {
|
|
51
|
+
...process.env,
|
|
52
|
+
GIT_AUTHOR_NAME: 'expo-cng',
|
|
53
|
+
GIT_COMMITTER_NAME: 'expo-cng',
|
|
54
|
+
GIT_AUTHOR_EMAIL: 'noreply@expo.dev',
|
|
55
|
+
GIT_COMMITTER_EMAIL: 'noreply@expo.dev',
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.commitAsync = commitAsync;
|
|
60
|
+
async function diffAsync(repoRoot, outputPatchFilePath, options) {
|
|
61
|
+
await runGitAsync(['diff', ...options, '--output', outputPatchFilePath], {
|
|
62
|
+
cwd: repoRoot,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
exports.diffAsync = diffAsync;
|
|
66
|
+
async function applyPatchAsync(projectRoot, patchFilePath) {
|
|
67
|
+
return await runGitAsync(['apply', patchFilePath], { cwd: projectRoot });
|
|
68
|
+
}
|
|
69
|
+
exports.applyPatchAsync = applyPatchAsync;
|
|
70
|
+
async function getPatchChangedLinesAsync(patchFilePath) {
|
|
71
|
+
const stdout = await runGitAsync(['apply', '--numstat', patchFilePath]);
|
|
72
|
+
const lines = stdout.split(/\r?\n/);
|
|
73
|
+
let changedLines = 0;
|
|
74
|
+
for (const line of lines) {
|
|
75
|
+
if (line === '') {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const [added, deleted] = line.split('\t', 2);
|
|
79
|
+
changedLines += Number(added) + Number(deleted);
|
|
80
|
+
}
|
|
81
|
+
return changedLines;
|
|
82
|
+
}
|
|
83
|
+
exports.getPatchChangedLinesAsync = getPatchChangedLinesAsync;
|
|
84
|
+
async function runGitAsync(args, options) {
|
|
85
|
+
try {
|
|
86
|
+
const { stdout, stderr } = await (0, spawn_async_1.default)('git', args, options);
|
|
87
|
+
if (env.EXPO_DEBUG) {
|
|
88
|
+
console.log(`Running \`git ${args}\` outputs:\nstdout:\n${stdout}\nstderr:\n${stderr}`);
|
|
89
|
+
}
|
|
90
|
+
return stdout.trim();
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
if (e.code === 'ENOENT') {
|
|
94
|
+
e.message += `\nGit is required to apply patches. Install Git and try again.`;
|
|
95
|
+
}
|
|
96
|
+
else if (e.stderr) {
|
|
97
|
+
e.message += `\nstderr:\n${e.stderr}`;
|
|
98
|
+
}
|
|
99
|
+
throw e;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async function generateDefaultGitignoreAsync(repoRoot) {
|
|
103
|
+
const contents = `\
|
|
104
|
+
# These files are generated by pod install and should not be included in patch files.
|
|
105
|
+
Podfile.lock
|
|
106
|
+
contents.xcworkspacedata
|
|
107
|
+
`;
|
|
108
|
+
await promises_1.default.writeFile(path_1.default.join(repoRoot, '.gitignore'), contents, 'utf8');
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=gitPatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitPatch.js","sourceRoot":"","sources":["../src/gitPatch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oEAA2C;AAC3C,2DAA6B;AAC7B,gDAAwB;AAExB,2CAA6B;AAEtB,KAAK,UAAU,sBAAsB,CAAC,QAAgB;IAC3D,IAAI;QACF,MAAM,kBAAE,CAAC,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;KAC5E;IAAC,MAAM,GAAE;IACV,MAAM,WAAW,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC/C,MAAM,6BAA6B,CAAC,QAAQ,CAAC,CAAC;AAChD,CAAC;AAND,wDAMC;AAEM,KAAK,UAAU,qBAAqB,CAAC,QAAgB;IAC1D,MAAM,WAAW,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;AACtD,CAAC;AAFD,sDAEC;AAEM,KAAK,UAAU,WAAW,CAAC,QAAgB,EAAE,OAAe;IACjE,MA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AO,YAAY,CAAC;AACtB,CAAC;AAZD,8DAYC;AAED,KAAK,UAAU,WAAW,CAAC,IAAc,EAAE,OAAiC;IAC1E,IAAI;QACF,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,qBAAU,EAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAClE,IAAI,GAAG,CAAC,UAAU,EAAE;YAClB,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,yBAAyB,MAAM,cAAc,MAAM,EAAE,CAAC,CAAC;SACzF;QACD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;KACtB;IAAC,OAAO,CAAM,EAAE;QACf,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;YACvB,CAAC,CAAC,OAAO,IAAI,gEAAgE,CAAC;SAC/E;aAAM,IAAI,CAAC,CAAC,MAAM,EAAE;YACnB,CAAC,CAAC,OAAO,IAAI,cAAc,CAAC,CAAC,MAAM,EAAE,CAAC;SACvC;QACD,MAAM,CAAC,CAAC;KACT;AACH,CAAC;AAED,KAAK,UAAU,6BAA6B,CAAC,QAAgB;IAC3D,MAAM,QAAQ,GAAG;;;;CAIlB,CAAC;IACA,MAAM,kBAAE,CAAC,SAAS,CAAC,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ConfigPlugin } from 'expo/config-plugins';
|
|
2
|
+
interface PatchPluginProps {
|
|
3
|
+
/** The directory to search for patch files in. */
|
|
4
|
+
patchRoot?: string;
|
|
5
|
+
/** The maximum changed lines allowed in the patch file, if exceeded the patch will show a warning. */
|
|
6
|
+
changedLinesLimit?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const withPatchPlugin: ConfigPlugin<PatchPluginProps | undefined>;
|
|
9
|
+
export default withPatchPlugin;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.withPatchPlugin = void 0;
|
|
30
|
+
const config_plugins_1 = require("expo/config-plugins");
|
|
31
|
+
const glob_1 = __importDefault(require("glob"));
|
|
32
|
+
const path_1 = __importDefault(require("path"));
|
|
33
|
+
const util_1 = require("util");
|
|
34
|
+
const env = __importStar(require("./env"));
|
|
35
|
+
const gitPatch_1 = require("./gitPatch");
|
|
36
|
+
const globAsync = (0, util_1.promisify)(glob_1.default);
|
|
37
|
+
const DEFAULT_PATCH_ROOT = 'cng-patches';
|
|
38
|
+
const DEFAULT_CHANGED_LINES_LIMIT = 300;
|
|
39
|
+
const withPatchPlugin = (config, props) => {
|
|
40
|
+
config = createPatchPlugin('android', props)(config);
|
|
41
|
+
config = createPatchPlugin('ios', props)(config);
|
|
42
|
+
return config;
|
|
43
|
+
};
|
|
44
|
+
exports.withPatchPlugin = withPatchPlugin;
|
|
45
|
+
exports.default = exports.withPatchPlugin;
|
|
46
|
+
const withPatchMod = (config, { platform, props }) => {
|
|
47
|
+
return (0, config_plugins_1.withFinalizedMod)(config, [
|
|
48
|
+
platform,
|
|
49
|
+
async (config) => {
|
|
50
|
+
const projectRoot = config.modRequest.projectRoot;
|
|
51
|
+
const templateChecksum = config._internal?.templateChecksum ?? '';
|
|
52
|
+
const patchFilePath = await determinePatchFilePathAsync(projectRoot, platform, templateChecksum, props);
|
|
53
|
+
if (patchFilePath != null) {
|
|
54
|
+
const changedLines = await (0, gitPatch_1.getPatchChangedLinesAsync)(patchFilePath);
|
|
55
|
+
const changedLinesLimit = props?.changedLinesLimit ?? DEFAULT_CHANGED_LINES_LIMIT;
|
|
56
|
+
if (changedLines > changedLinesLimit) {
|
|
57
|
+
config_plugins_1.WarningAggregator.addWarningForPlatform(platform, 'withPatchPlugin', `The patch file "${patchFilePath}" has ${changedLines} changed lines, which exceeds the limit of ${changedLinesLimit}.`);
|
|
58
|
+
}
|
|
59
|
+
await (0, gitPatch_1.applyPatchAsync)(projectRoot, patchFilePath);
|
|
60
|
+
}
|
|
61
|
+
return config;
|
|
62
|
+
},
|
|
63
|
+
]);
|
|
64
|
+
};
|
|
65
|
+
function createPatchPlugin(platform, props) {
|
|
66
|
+
const platformName = platform.charAt(0).toUpperCase() + platform.slice(1);
|
|
67
|
+
const pluginName = `with${platformName}PatchPlugin`;
|
|
68
|
+
const withUnknown = (config) => {
|
|
69
|
+
return (0, config_plugins_1.withRunOnce)(config, {
|
|
70
|
+
plugin: (config) => withPatchMod(config, { platform, props }),
|
|
71
|
+
name: pluginName,
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
Object.defineProperty(withUnknown, 'name', {
|
|
75
|
+
value: pluginName,
|
|
76
|
+
});
|
|
77
|
+
return withUnknown;
|
|
78
|
+
}
|
|
79
|
+
async function determinePatchFilePathAsync(projectRoot, platform, templateChecksum, props) {
|
|
80
|
+
const patchRoot = path_1.default.join(projectRoot, props?.patchRoot ?? DEFAULT_PATCH_ROOT);
|
|
81
|
+
const patchFilePath = path_1.default.join(patchRoot, `${platform}+${templateChecksum}.patch`);
|
|
82
|
+
const patchFiles = await getPatchFilesAsync(patchRoot, platform);
|
|
83
|
+
const patchExists = patchFiles.includes(path_1.default.basename(patchFilePath));
|
|
84
|
+
if (patchFiles.length > 0 && !patchExists) {
|
|
85
|
+
const firstPatchFilePath = path_1.default.join(patchRoot, patchFiles[0]);
|
|
86
|
+
config_plugins_1.WarningAggregator.addWarningForPlatform(platform, 'withPatchPlugin', `Having patch files in ${patchRoot} but none matching "${patchFilePath}", using "${firstPatchFilePath}" instead.`);
|
|
87
|
+
}
|
|
88
|
+
else if (patchFiles.length > 1) {
|
|
89
|
+
config_plugins_1.WarningAggregator.addWarningForPlatform(platform, 'withPatchPlugin', `Having multiple patch files in ${patchRoot} is not supported. Only matched patch file "${patchFilePath}" will be applied.`);
|
|
90
|
+
}
|
|
91
|
+
if (env.EXPO_DEBUG) {
|
|
92
|
+
console.log(patchExists
|
|
93
|
+
? `[withPatchPlugin] Applying patch from ${patchFilePath}`
|
|
94
|
+
: `[WithPatchPlugin] No patch found: ${patchFilePath}`);
|
|
95
|
+
}
|
|
96
|
+
if (!patchExists) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return patchFilePath;
|
|
100
|
+
}
|
|
101
|
+
async function getPatchFilesAsync(patchRoot, platform) {
|
|
102
|
+
return await globAsync(`${platform}*.patch`, { cwd: patchRoot });
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=withPatchPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withPatchPlugin.js","sourceRoot":"","sources":["../src/withPatchPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAM6B;AAC7B,gDAAwB;AACxB,gDAAwB;AACxB,+BAAiC;AAEjC,2CAA6B;AAC7B,yCAAwE;AAExE,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,cAAI,CAAC,CAAC;AAElC,MAAM,kBAAkB,GAAG,aAAa,CAAC;AACzC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AASjC,MAAM,eAAe,GAA+C,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;IAC3F,MAAM,GAAG,iBAAiB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;IACrD,MAAM,GAAG,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAJW,QAAA,eAAe,mBAI1B;AAEF,kBAAe,uBAAe,CAAC;AAE/B,MAAM,YAAY,GAAiF,CACjG,MAAM,EACN,EAAE,QAAQ,EAAE,KAAK,EAAE,EACnB,EAAE;IACF,OAAO,IAAA,iCAAgB,EAAC,MAAM,EAAE;QAC9B,QAAQ;QACR,KAAK,EAAE,MAAM,EAAE,EAAE;YACf,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC;YAClD,MAAM,gBAAgB,GAAG,MAAM,CAAC,SAAS,EAAE,gBAAgB,IAAI,EAAE,CAAC;YAClE,MAAM,aAAa,GAAG,MAAM,2BAA2B,CACrD,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,KAAK,CACN,CAAC;YACF,IAAI,aAAa,IAAI,IAAI,EAAE;gBACzB,MAAM,YAAY,GAAG,MAAM,IAAA,oCAAyB,EAAC,a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4
|
-
"description": "",
|
|
5
|
-
"main": "
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "An Expo config-plugin and tool to support patch-based CNG",
|
|
5
|
+
"main": "build/withPatchPlugin.js",
|
|
6
|
+
"types": "build/withPatchPlugin.d.ts",
|
|
6
7
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
+
"build": "expo-module tsc",
|
|
9
|
+
"clean": "expo-module clean",
|
|
10
|
+
"lint": "expo-module lint",
|
|
11
|
+
"prepare": "expo-module clean && expo-module tsc",
|
|
12
|
+
"prepublishOnly": "expo-module prepublishOnly",
|
|
13
|
+
"test": "expo-module test",
|
|
14
|
+
"test:e2e": "expo-module clean && expo-module tsc && expo-module test --config e2e/jest.config.js",
|
|
15
|
+
"typecheck": "expo-module typecheck",
|
|
16
|
+
"watch": "expo-module tsc --watch"
|
|
8
17
|
},
|
|
9
|
-
"
|
|
10
|
-
|
|
18
|
+
"bin": {
|
|
19
|
+
"patch-project": "build/cli/index.js"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"app.plugin.js",
|
|
23
|
+
"build"
|
|
24
|
+
],
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/expo/expo.git",
|
|
28
|
+
"directory": "packages/patch-project"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"expo",
|
|
32
|
+
"cng",
|
|
33
|
+
"prebuild",
|
|
34
|
+
"patch",
|
|
35
|
+
"project"
|
|
36
|
+
],
|
|
37
|
+
"author": "650 Industries, Inc.",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/expo/expo/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/expo/expo/tree/main/packages/patch-project#readme",
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"expo-module-scripts": "^3.3.0",
|
|
45
|
+
"memfs": "^3.2.0"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@expo/config": "~8.5.0",
|
|
49
|
+
"@expo/config-plugins": "~7.8.0",
|
|
50
|
+
"@expo/spawn-async": "^1.7.2",
|
|
51
|
+
"arg": "5.0.2",
|
|
52
|
+
"chalk": "^4.0.0",
|
|
53
|
+
"debug": "^4.3.1",
|
|
54
|
+
"fs-extra": "^9.1.0",
|
|
55
|
+
"glob": "^7.1.7",
|
|
56
|
+
"resolve-from": "^5.0.0"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"expo": ">=50.0.0"
|
|
60
|
+
}
|
|
11
61
|
}
|