Skip to content

Commit

Permalink
Merge pull request #271 from Flagsmith/fix/sourcemaps
Browse files Browse the repository at this point in the history
fix: sourcemaps
  • Loading branch information
kyle-ssg authored Dec 18, 2024
2 parents 7dd0bf0 + 1b65819 commit 1af570b
Show file tree
Hide file tree
Showing 7 changed files with 260 additions and 31 deletions.
2 changes: 1 addition & 1 deletion lib/flagsmith-es/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flagsmith-es",
"version": "8.0.0",
"version": "8.0.1",
"description": "Feature flagging to support continuous development. This is an esm equivalent of the standard flagsmith npm module.",
"main": "./index.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion lib/flagsmith/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flagsmith",
"version": "8.0.0",
"version": "8.0.1",
"description": "Feature flagging to support continuous development",
"main": "./index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion lib/react-native-flagsmith/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-flagsmith",
"version": "8.0.0",
"version": "8.0.1",
"description": "Feature flagging to support continuous development",
"main": "./index.js",
"repository": {
Expand Down
44 changes: 39 additions & 5 deletions move-react.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const path = require("path")
const fs = require("fs")
const fsExtra = require('fs-extra')

const replaceInFileSync = (file,from,to) => {
const replaceInFileSync = (file, from, to) => {
const data = fs.readFileSync(file, 'utf8');
const newData = data.replace(from, to)
fs.writeFileSync(file, newData, {encoding:"utf8"})
const newData = data.replace(new RegExp(from, 'g'), to);
fs.writeFileSync(file, newData, { encoding: "utf8" });
}


Expand Down Expand Up @@ -43,8 +44,6 @@ fs.copyFileSync(path.join(__dirname,"isomorphic-es.ts"),path.join(__dirname,"lib





const files= fs.readdirSync(path.join(__dirname, "lib/flagsmith"));
files.forEach((fileName)=>{
console.log(fileName)
Expand All @@ -56,6 +55,12 @@ files.forEach((fileName)=>{
// fix paths in flagsmith/index.js sourcemaps
replaceInFileSync(path.join(__dirname, "lib/flagsmith/index.js.map"),"../../../flagsmith-core.ts","./src/flagsmith-core.ts" )
replaceInFileSync(path.join(__dirname, "lib/flagsmith/index.js.map"),"../../../index.ts","./src/index.ts" )
replaceInFileSync(path.join(__dirname, "lib/flagsmith/index.js.map"),"../../../utils","./src/utils" )
replaceInFileSync(path.join(__dirname, "lib/flagsmith-es/index.js.map"),"../../../utils","./src/utils" )
replaceInFileSync(path.join(__dirname, "lib/react-native-flagsmith/index.js.map"),"../../../utils","./src/utils" )
replaceInFileSync(path.join(__dirname, "lib/flagsmith/react.js.map"),"../../../utils","./src/utils" )
replaceInFileSync(path.join(__dirname, "lib/flagsmith-es/react.js.map"),"../../../utils","./src/utils" )
replaceInFileSync(path.join(__dirname, "lib/react-native-flagsmith/react.js.map"),"../../../utils","./src/utils" )

// fix paths in flagsmith-es/index.js sourcemaps
replaceInFileSync(path.join(__dirname, "lib/flagsmith-es/index.js.map"),"../../../flagsmith-core.ts","./src/flagsmith-core.ts" )
Expand Down Expand Up @@ -121,3 +126,32 @@ try {
try {
fs.rmdirSync(path.join(__dirname,"lib/react-native-flagsmith/test"), {recursive:true})
} catch (e){}



function syncFolders(src, dest) {
try {
// Ensure the destination folder exists
fsExtra.ensureDirSync(dest);

const entries = fs.readdirSync(src, { withFileTypes: true });

for (const entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);

if (entry.isFile()) {
// Copy only files to the destination, overwriting existing files
fs.copyFileSync(srcPath, destPath);
}
}

console.log('Folders synchronized successfully!', src, dest);
} catch (err) {
console.error('Error synchronizing folders:', err);
}
}

syncFolders(path.join(__dirname,'utils'),path.join(__dirname,'lib/flagsmith/src/utils'))
syncFolders(path.join(__dirname,'utils'),path.join(__dirname,'lib/flagsmith-es/src/utils'))
syncFolders(path.join(__dirname,'utils'),path.join(__dirname,'lib/react-native-flagsmith/src/utils'))
6 changes: 6 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"watch": ["."],
"ignore": ["node_modules", "lib", "examples"],
"ext": "js,ts,tsx,json",
"exec": "npm run bundle"
}
Loading

0 comments on commit 1af570b

Please sign in to comment.