Skip to content

Commit

Permalink
Windows issue (#270)
Browse files Browse the repository at this point in the history
* Windows issue with open npm lib
* Upgrade to 5.0.2

---------

Co-authored-by: vivek-gofynd <[email protected]>
  • Loading branch information
vivek-gofynd and vivek-gofynd authored Feb 13, 2024
1 parent 143c8c6 commit c89371f
Show file tree
Hide file tree
Showing 17 changed files with 596 additions and 455 deletions.
40 changes: 21 additions & 19 deletions bin/fdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,32 @@ const currentNodeVersion = process.versions.node;
const semver = currentNodeVersion.split('.');
const major = Number(semver[0]);

const Sentry = require("@sentry/node");
const packageJson = require("../package.json");
const Sentry = require('@sentry/node');
const packageJson = require('../package.json');

Sentry.init({
dsn: "https://[email protected]/4506539889721344",
release: packageJson.version
})
dsn: 'https://[email protected]/4506539889721344',
release: packageJson.version,
});

const bootstrap = () => {
const { init, parseCommands } = require('../dist/fdk');
const program = init('fdk');
parseCommands();
return program;
}
const { init, parseCommands } = require('../dist/fdk');
const program = init('fdk');
parseCommands();
return program;
};

if (major < 12) {
console.error(chalk.red(
'You are running Node ' +
currentNodeVersion +
'.\n' +
'Fynd development kit requires Node 12 or higher. \n' +
'Please update your version of Node.'
));
process.exit(1);
console.error(
chalk.red(
'You are running Node ' +
currentNodeVersion +
'.\n' +
'Fynd development kit requires Node 12 or higher. \n' +
'Please update your version of Node.',
),
);
process.exit(1);
}

bootstrap();
bootstrap();
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gofynd/fdk-cli",
"version": "5.0.1",
"version": "5.0.2",
"main": "index.js",
"license": "MIT",
"bin": {
Expand Down
1 change: 0 additions & 1 deletion rolex
Submodule rolex deleted from 139386
28 changes: 19 additions & 9 deletions scripts/stableReleaseCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,36 @@ const packageJSON = require('../package.json');
const packageJSONVersion = packageJSON.version;

// Check if version is valid
if(!packageJSONVersion.match(versionRegex)){
console.log(`\x1b[33m Invalid version in package.json(${packageJSONVersion}). Release aborted ! \x1b[0m`);
console.log('\x1b[33m Stable Release version should match regex:\x1b[0m ^\\d+\\.\\d+\\.\\d+$');
if (!packageJSONVersion.match(versionRegex)) {
console.log(
`\x1b[33m Invalid version in package.json(${packageJSONVersion}). Release aborted ! \x1b[0m`,
);
console.log(
'\x1b[33m Stable Release version should match regex:\x1b[0m ^\\d+\\.\\d+\\.\\d+$',
);
return process.exit(1);
}

const gitRef = process.env.GITHUB_REF;
const tagVersion = gitRef.match(/^refs\/tags\/v(\d+\.\d+\.\d+)/)?.[1];

// Check if Release Tag version is valid
if(!tagVersion){
console.log(`\x1b[33m Invalid version in Release Tag(${gitRef}). Release aborted ! \x1b[0m`);
console.log('\x1b[33m Stable Release Tag version should match regex:\x1b[0m ^v\\d+\\.\\d+\\.\\d+$');
if (!tagVersion) {
console.log(
`\x1b[33m Invalid version in Release Tag(${gitRef}). Release aborted ! \x1b[0m`,
);
console.log(
'\x1b[33m Stable Release Tag version should match regex:\x1b[0m ^v\\d+\\.\\d+\\.\\d+$',
);
return process.exit(1);
}

// Check if version in Release tag and package.json matches
if(packageJSONVersion !== tagVersion){
console.log(`\x1b[33m Release Tag version(${tagVersion}) and package.json(${packageJSONVersion}) didn\'t match. Release aborted ! \x1b[0m`);
if (packageJSONVersion !== tagVersion) {
console.log(
`\x1b[33m Release Tag version(${tagVersion}) and package.json(${packageJSONVersion}) didn\'t match. Release aborted ! \x1b[0m`,
);
return process.exit(1);
}

console.log('\x1b[32m Release initiated ! \x1b[0m');
console.log('\x1b[32m Release initiated ! \x1b[0m');
32 changes: 22 additions & 10 deletions scripts/unstableReleaseCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,38 @@ const packageJSON = require('../package.json');
const packageJSONVersion = packageJSON.version;

// Check if version is valid
if(!packageJSONVersion.match(versionRegex)){
console.log(`\x1b[33m Invalid version in package.json(${packageJSONVersion}). Release aborted ! \x1b[0m`);
console.log('\x1b[33m Unstable version should match regex:\x1b[0m ^\\d+\\.\\d+\\.\\d+-(alpha|beta)\\.\\d+$');
if (!packageJSONVersion.match(versionRegex)) {
console.log(
`\x1b[33m Invalid version in package.json(${packageJSONVersion}). Release aborted ! \x1b[0m`,
);
console.log(
'\x1b[33m Unstable version should match regex:\x1b[0m ^\\d+\\.\\d+\\.\\d+-(alpha|beta)\\.\\d+$',
);
return process.exit(1);
}

const gitRef = process.env.GITHUB_REF;
const tagVersion = gitRef.match(/^refs\/tags\/v(\d+\.\d+\.\d+-(?:alpha|beta)\.\d+)/)?.[1];
const tagVersion = gitRef.match(
/^refs\/tags\/v(\d+\.\d+\.\d+-(?:alpha|beta)\.\d+)/,
)?.[1];

// Check if Release Tag version is valid
if(!tagVersion){
console.log(`\x1b[33m Invalid version in Tag(${gitRef}). Release aborted ! \x1b[0m`);
console.log('\x1b[33m Unstable Tag version should match regex:\x1b[0m ^v\\d+\\.\\d+\\.\\d+-(alpha|beta)\\.\\d+$');
if (!tagVersion) {
console.log(
`\x1b[33m Invalid version in Tag(${gitRef}). Release aborted ! \x1b[0m`,
);
console.log(
'\x1b[33m Unstable Tag version should match regex:\x1b[0m ^v\\d+\\.\\d+\\.\\d+-(alpha|beta)\\.\\d+$',
);
return process.exit(1);
}

// Check if version in Release tag and package.json matches
if(packageJSONVersion !== tagVersion){
console.log(`\x1b[33m Tag version(${tagVersion}) and package.json(${packageJSONVersion}) didn\'t match. Release aborted ! \x1b[0m`);
if (packageJSONVersion !== tagVersion) {
console.log(
`\x1b[33m Tag version(${tagVersion}) and package.json(${packageJSONVersion}) didn\'t match. Release aborted ! \x1b[0m`,
);
return process.exit(1);
}

console.log('\x1b[32m Release initiated ! \x1b[0m');
console.log('\x1b[32m Release initiated ! \x1b[0m');
14 changes: 10 additions & 4 deletions src/fdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Command.prototype.asyncAction = async function (asyncFn: Action) {
else break;
}

if(parent._optionValues.verbose || parent._optionValues.debug) {
if (parent._optionValues.verbose || parent._optionValues.debug) {
parent._optionValues.verbose = true;
parent._optionValues.debug = true;
}
Expand Down Expand Up @@ -215,9 +215,15 @@ export async function init(programName: string) {
program
.name(programName)
.version(packageJSON.version)
.option('-v, --verbose', 'Display detailed output for debugging purposes')
.option('-d, --debug', 'Display detailed output for debugging purposes');

.option(
'-v, --verbose',
'Display detailed output for debugging purposes',
)
.option(
'-d, --debug',
'Display detailed output for debugging purposes',
);

//register commands with commander instance
registerCommands(program);
//set API versios
Expand Down
53 changes: 32 additions & 21 deletions src/helper/serve.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let headers = {
'Content-Type': 'application/json',
Accept: 'application/json',
'x-fp-cli': `${packageJSON.version}`,
}
};

export function reload() {
sockets.forEach((s) => {
Expand Down Expand Up @@ -110,7 +110,7 @@ async function setupServer({ domain }) {
app.use(express.json());

app.use('/public', async (req, res, done) => {
const themeId = currentContext.theme_id;
const themeId = currentContext.theme_id;
const { url } = req;
try {
if (publicCache[url]) {
Expand All @@ -121,7 +121,9 @@ async function setupServer({ domain }) {
}
return res.send(publicCache[url].body);
}
const networkRes = await axios.get(urlJoin(domain, 'public', url, `?themeId=${themeId}`));
const networkRes = await axios.get(
urlJoin(domain, 'public', url, `?themeId=${themeId}`),
);
publicCache[url] = publicCache[url] || {};
publicCache[url].body = networkRes.data;
publicCache[url].headers = networkRes.headers;
Expand Down Expand Up @@ -263,17 +265,20 @@ export async function startServer({ domain, host, isSSR, port }) {
stack?.forEach(({ methodName, lineNumber, column }) => {
try {
if (lineNumber == null || lineNumber < 1) {
errorString += `<p> at <strong>${methodName || ''
}</strong></p>`;
errorString += `<p> at <strong>${
methodName || ''
}</strong></p>`;
} else {
const pos = smc.originalPositionFor({
line: lineNumber,
column,
});
if (pos && pos.line != null) {
errorString += `<p> at <strong>${methodName || pos.name || ''
}</strong> (${pos.source}:${pos.line}:${pos.column
})</p>`;
errorString += `<p> at <strong>${
methodName || pos.name || ''
}</strong> (${pos.source}:${pos.line}:${
pos.column
})</p>`;
}
}
} catch (err) {
Expand All @@ -298,7 +303,8 @@ export async function startServer({ domain, host, isSSR, port }) {
return reject(err);
}
Logger.info(
`Starting starter at port -- ${port} in ${isSSR ? 'SSR' : 'Non-SSR'
`Starting starter at port -- ${port} in ${
isSSR ? 'SSR' : 'Non-SSR'
} mode`,
);
Logger.info(`************* Using Debugging build`);
Expand Down Expand Up @@ -414,15 +420,19 @@ export async function startReactServer({ domain, host, isHMREnabled, port }) {
await Promise.all(promises);

const { data: html } = await axios
.post(skyfireUrl.toString(), {
themeURLs,
cliMeta: {
port,
domain: getFullLocalUrl(port),
.post(
skyfireUrl.toString(),
{
themeURLs,
cliMeta: {
port,
domain: getFullLocalUrl(port),
},
},
}, {
headers
})
{
headers,
},
)
.catch((error) => {
console.log(error);
return { data: error };
Expand All @@ -433,8 +443,9 @@ export async function startReactServer({ domain, host, isHMREnabled, port }) {
<script>
var socket = io();
socket.on('reload',function(){
${isHMREnabled
? `
${
isHMREnabled
? `
try {
window.APP_DATA.themeBundleUMDURL = '/themeBundle.umd.js';
window.APP_DATA.isServerRendered = false;
Expand All @@ -447,10 +458,10 @@ export async function startReactServer({ domain, host, isHMREnabled, port }) {
window.loadApp().catch(console.log);
} catch(e) { console.log( e );}
`
: `
: `
window.location.reload();
`
}
}
});
</script>
Expand Down
Loading

0 comments on commit c89371f

Please sign in to comment.