mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
eslint-plugin-specs prepublish step
Summary: #Changelog: [Internal] - This is an attempt to fix public publishing of eslint-plugin-specs. Currently, internal consumption of this package assumes access to `react-native-codegen/src` but for external usage, we leverage the published `react-native-codegen` which transforms files out to the `lib` folder vs. `src`. For a similar-ish suit, this change is adding a prepublish step that will very basically update the references. Reviewed By: mdvacca Differential Revision: D32910080 fbshipit-source-id: f5e508090cbbf5097a848ddef3b721002a6c6277
This commit is contained in:
committed by
Facebook GitHub Bot
parent
60e60a9b3d
commit
2d06e6a4c9
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@react-native/eslint-plugin-specs",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.2",
|
||||
"description": "ESLint rules to validate NativeModule and Component Specs",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -8,6 +8,9 @@
|
||||
"url": "git@github.com:facebook/react-native.git",
|
||||
"directory": "packages/eslint-plugin-specs"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "node prepublish.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.14.0",
|
||||
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
/**
|
||||
* script to prepare package for publish.
|
||||
*
|
||||
* Due to differences to how we consume internal packages, update a flag
|
||||
*/
|
||||
|
||||
fs.readFile('./react-native-modules.js', 'utf8', function (readError, source) {
|
||||
if (readError != null) {
|
||||
return console.error(
|
||||
'Failed to read react-native-modules.js for publish',
|
||||
readError,
|
||||
);
|
||||
}
|
||||
|
||||
const result = source.replace(
|
||||
'const PACKAGE_USAGE = false;',
|
||||
'const PACKAGE_USAGE = true;',
|
||||
);
|
||||
|
||||
fs.writeFile(
|
||||
'./react-native-modules.js',
|
||||
result,
|
||||
'utf8',
|
||||
function (writeError) {
|
||||
if (writeError != null) {
|
||||
return console.error(
|
||||
'Failed to update react-native-modules.js for publish',
|
||||
writeError,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
+23
-8
@@ -13,6 +13,8 @@
|
||||
const path = require('path');
|
||||
const withBabelRegister = require('./with-babel-register');
|
||||
|
||||
// We run yarn prepublish before publishing package which will set this value to true
|
||||
const PACKAGE_USAGE = false;
|
||||
const ERRORS = {
|
||||
misnamedHasteModule(hasteModuleName) {
|
||||
return `Module ${hasteModuleName}: All files using TurboModuleRegistry must start with Native.`;
|
||||
@@ -24,15 +26,28 @@ let RNParserUtils;
|
||||
|
||||
function requireModuleParser() {
|
||||
if (RNModuleParser == null || RNParserUtils == null) {
|
||||
const config = {
|
||||
only: [/react-native-codegen\/src\//],
|
||||
plugins: [require('@babel/plugin-transform-flow-strip-types').default],
|
||||
};
|
||||
// If using this externally, we leverage react-native-codegen as published form
|
||||
if (!PACKAGE_USAGE) {
|
||||
const config = {
|
||||
only: [/react-native-codegen\/src\//],
|
||||
plugins: [require('@babel/plugin-transform-flow-strip-types').default],
|
||||
};
|
||||
|
||||
withBabelRegister(config, () => {
|
||||
RNModuleParser = require('react-native-codegen/src/parsers/flow/modules');
|
||||
RNParserUtils = require('react-native-codegen/src/parsers/flow/utils');
|
||||
});
|
||||
withBabelRegister(config, () => {
|
||||
RNModuleParser = require('react-native-codegen/src/parsers/flow/modules');
|
||||
RNParserUtils = require('react-native-codegen/src/parsers/flow/utils');
|
||||
});
|
||||
} else {
|
||||
const config = {
|
||||
only: [/react-native-codegen\/lib\//],
|
||||
plugins: [require('@babel/plugin-transform-flow-strip-types').default],
|
||||
};
|
||||
|
||||
withBabelRegister(config, () => {
|
||||
RNModuleParser = require('react-native-codegen/lib/parsers/flow/modules');
|
||||
RNParserUtils = require('react-native-codegen/lib/parsers/flow/utils');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user