Skip to content

Commit

Permalink
[WIP] Move @generated signing from build to sync
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Jun 7, 2024
1 parent 25f9c80 commit ebb616f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 33 deletions.
20 changes: 0 additions & 20 deletions scripts/rollup/packaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ const {
readFileSync,
writeFileSync,
} = require('fs');
const path = require('path');
const Bundles = require('./bundles');
const {
asyncCopyTo,
asyncExecuteCommand,
asyncExtractTar,
asyncRimRaf,
} = require('./utils');
const {getSigningToken, signFile} = require('signedsource');

const {
NODE_ES2015,
Expand Down Expand Up @@ -127,24 +125,6 @@ async function copyRNShims() {
require.resolve('react-native-renderer/src/ReactNativeTypes.js'),
'build/react-native/shims/ReactNativeTypes.js'
);
processGenerated('build/react-native/shims');
}

function processGenerated(directory) {
const files = readdirSync(directory)
.filter(dir => dir.endsWith('.js'))
.map(file => path.join(directory, file));

files.forEach(file => {
const originalContents = readFileSync(file, 'utf8');
const contents = originalContents
// Replace {@}format with {@}noformat
.replace(/(\r?\n\s*\*\s*)@format\b.*(\n)/, '$1@noformat$2')
// Add {@}nolint and {@}generated
.replace(/(\r?\n\s*\*)\//, `$1 @nolint$1 ${getSigningToken()}$1/`);
const signedContents = signFile(contents);
writeFileSync(file, signedContents, 'utf8');
});
}

async function copyAllShims() {
Expand Down
25 changes: 12 additions & 13 deletions scripts/rollup/wrappers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const {signFile, getSigningToken} = require('signedsource');
const {bundleTypes, moduleTypes} = require('./bundles');

const {
Expand Down Expand Up @@ -392,7 +391,7 @@ ${source}`;

/****************** RN_OSS_DEV ******************/
[RN_OSS_DEV](source, globalName, filename, moduleType) {
return signFile(`/**
return `/**
${license}
*
* @noflow
Expand All @@ -401,12 +400,12 @@ ${license}
* ${getSigningToken()}
*/
${source}`);
${source}`;
},

/****************** RN_OSS_PROD ******************/
[RN_OSS_PROD](source, globalName, filename, moduleType) {
return signFile(`/**
return `/**
${license}
*
* @noflow
Expand All @@ -415,12 +414,12 @@ ${license}
* ${getSigningToken()}
*/
${source}`);
${source}`;
},

/****************** RN_OSS_PROFILING ******************/
[RN_OSS_PROFILING](source, globalName, filename, moduleType) {
return signFile(`/**
return `/**
${license}
*
* @noflow
Expand All @@ -429,12 +428,12 @@ ${license}
* ${getSigningToken()}
*/
${source}`);
${source}`;
},

/****************** RN_FB_DEV ******************/
[RN_FB_DEV](source, globalName, filename, moduleType) {
return signFile(`/**
return `/**
${license}
*
* @noflow
Expand All @@ -443,12 +442,12 @@ ${license}
* ${getSigningToken()}
*/
${source}`);
${source}`;
},

/****************** RN_FB_PROD ******************/
[RN_FB_PROD](source, globalName, filename, moduleType) {
return signFile(`/**
return `/**
${license}
*
* @noflow
Expand All @@ -457,12 +456,12 @@ ${license}
* ${getSigningToken()}
*/
${source}`);
${source}`;
},

/****************** RN_FB_PROFILING ******************/
[RN_FB_PROFILING](source, globalName, filename, moduleType) {
return signFile(`/**
return `/**
${license}
*
* @noflow
Expand All @@ -471,7 +470,7 @@ ${license}
* ${getSigningToken()}
*/
${source}`);
${source}`;
},
};

Expand Down

0 comments on commit ebb616f

Please sign in to comment.