Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V5.2.0 release #326

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8f0538e
mearge fix one
prashant-fynd May 14, 2024
ac4e722
ID:FPCO-30358;DONE:100;HOURS:38;fix with new react webpack config
prashant-fynd May 16, 2024
714fc4a
Merge branch 'new-cli-release' into cdn-new-cli
prashant-fynd May 16, 2024
beb300b
ID:FPCO-30358;DONE:100;HOURS:38;fix vue init error
prashant-fynd May 16, 2024
7287ce0
ID:FPCO-30358;DONE:100;HOURS:38;rolex removal
prashant-fynd May 16, 2024
72c25ba
ID:FPCO-30358;DONE:100;HOURS:38;import file upload
prashant-fynd May 16, 2024
0df1057
Merge branch 'master' into cdn-new-cli
prashant-fynd May 16, 2024
1cd18a7
ID:FPCO-30358;DONE:100;HOURS:38;vue import file path change
prashant-fynd May 16, 2024
8080c23
ID:FPCO-34269;DONE:100;HOURS:10;dev-prod saparate build
meetdhananifynd Jun 20, 2024
7de2685
use CDN key from grindor completed API
ashokrdkr Jul 5, 2024
45f08dc
remove version compatibility api usage
ashokrdkr Jul 5, 2024
832237a
remove version compatibility messages
ashokrdkr Jul 8, 2024
890a5e9
Merge branch 'master' into grindor-complete-cdn
karanrainafynd Jul 10, 2024
cc8c87f
Merge branch 'master' into deprecate-compatibility-usage
karanrainafynd Jul 10, 2024
fe7ab5a
Fix grindor cdn URL
karanrainafynd Jul 10, 2024
99c37a9
Fix grindor cdn URL
karanrainafynd Jul 10, 2024
af67b10
align with master
karanrainafynd Jul 10, 2024
6ce14b4
add some dummy content to file so it gets uploaded
karanrainafynd Jul 10, 2024
1de114c
Merge branch 'master' of github.com:gofynd/fdk-cli
meetdhananifynd Jul 11, 2024
f0b0042
Merge remote-tracking branch 'origin/deprecate-compatibility-usage' i…
meetdhananifynd Jul 11, 2024
b8e60b5
Merge remote-tracking branch 'origin/grindor-complete-cdn' into v5.2.…
meetdhananifynd Jul 11, 2024
35a84f2
Merge remote-tracking branch 'origin/cdn-new-cli' into v5.2.0-release
meetdhananifynd Jul 11, 2024
9898fdd
version bump
meetdhananifynd Jul 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.1.2",
"version": "5.2.0",
"main": "index.js",
"license": "MIT",
"bin": {
Expand Down
2 changes: 2 additions & 0 deletions sample-upload.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions sample-upload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// ! DO NOT REMOVE
// This file is used to get CDN base path
1 change: 0 additions & 1 deletion src/__tests__/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ describe('Auth Commands', () => {
setEnv();
program = await init('fdk');
const mock = new MockAdapter(axios);
mock.onGet(`${URLS.IS_VERSION_COMPATIBLE()}`).reply(200);
await login();
});

Expand Down
1 change: 0 additions & 1 deletion src/__tests__/theme.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ describe('Theme Commands', () => {
const mockInstance = new MockAdapter(
uninterceptedApiClient.axiosInstance,
);
mock.onGet(`${URLS.IS_VERSION_COMPATIBLE()}`).reply(200);
mock.onGet(
`${URLS.GET_APPLICATION_DETAILS(
appConfig.company_id,
Expand Down
1 change: 0 additions & 1 deletion src/__tests__/themeContext.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ describe('Theme Context Commands', () => {
setEnv();
program = await init('fdk');
const mock = new MockAdapter(axios);
mock.onGet(`${URLS.IS_VERSION_COMPATIBLE()}`).reply(200);
mock.onGet(
`${URLS.GET_APPLICATION_DETAILS(
appConfig.company_id,
Expand Down
70 changes: 66 additions & 4 deletions src/helper/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,32 @@ import webpack, { MultiStats } from 'webpack';
import createBaseWebpackConfig from '../helper/theme.react.config';
import fs from 'fs';
import rimraf from 'rimraf';
import Logger from '../lib/Logger';

export const THEME_ENTRY_FILE = path.join('theme', 'index.js');
export const VUE_THEME_ENTRY_FILE = path.join("..",'theme', 'index.js');
export const DEV_VUE_THEME_ENTRY_FILE = path.join('theme', 'index.js');

export const CDN_ENTRY_FILE = path.join('.fdk', 'cdn_index.js');

export const dynamicCDNScript = ({assetNormalizedBasePath,vueJs }) => {
return `function getCDNurl() {
\n let cdnUrl;
\n try{
\n if(fynd_platform_cdn) {
\n cdnUrl = fynd_platform_cdn
\n } else {
\n throw new Error("undefiend variable")}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why throwing error is needed when simply assignment of assetNormalizedBasePath is required?
Also code needs to be formatted

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can omit try-catch altogether here, Doesn't seems it is required here.

\n } catch(error){
\n cdnUrl = '${assetNormalizedBasePath}'}
\n return cdnUrl;
\n }
\n __webpack_public_path__ = getCDNurl() ${vueJs ? `\n
import bundle from "../theme/index.js";
\n export default bundle;
`
: ''}`
}
export function build({
buildFolder,
imageCdnUrl,
Expand All @@ -23,13 +46,23 @@ export function build({
'bin',
'vue-cli-service.js',
);
fs.stat(CDN_ENTRY_FILE, function (err, stat) {
if (err == null) {
//deleting file if exist
fs.unlink(CDN_ENTRY_FILE, function (err) {
if (err) return console.log(err);
Logger.debug(' \n Existing file deleted successfully');
});
}
fs.appendFileSync(CDN_ENTRY_FILE, dynamicCDNScript({ assetNormalizedBasePath:(imageCdnUrl|| assetCdnUrl),vueJs: true }));
});
const spinner = new Spinner('Building assets using vue-cli-service');
return new Promise((resolve, reject) => {
spinner.start();
const isNodeVersionIsGreaterThan18 =
+process.version.split('.')[0].slice(1) >= 18;
let b = exec(
`node ${VUE_CLI_PATH} build --target lib --dest ${buildFolder} --name themeBundle --filename ${assetHash}_themeBundle ${THEME_ENTRY_FILE}`,
`node ${VUE_CLI_PATH} build --target lib --dest ${buildFolder} --name themeBundle --filename ${assetHash}_themeBundle ${CDN_ENTRY_FILE}`,
{
cwd: process.cwd(),
env: {
Expand All @@ -53,6 +86,10 @@ export function build({
b.stdout.pipe(process.stdout);
b.stderr.pipe(process.stderr);
b.on('exit', function (code) {
fs.unlink(CDN_ENTRY_FILE, function (err) {
if (err) return console.log(err);
Logger.debug(' \n Existing file deleted successfully');
});
if (!code) {
spinner.succeed();
return resolve(true);
Expand All @@ -75,6 +112,7 @@ interface DevReactBuild {
imageCdnUrl?: string;
localThemePort?: string;
isHMREnabled: boolean;
targetDirectory?:string
}

export function devBuild({ buildFolder, imageCdnUrl, isProd }: DevBuild) {
Expand All @@ -91,7 +129,7 @@ export function devBuild({ buildFolder, imageCdnUrl, isProd }: DevBuild) {

return new Promise((resolve, reject) => {
let b = exec(
`node ${VUE_CLI_PATH} build --target lib --dest ${buildFolder} --name themeBundle ${THEME_ENTRY_FILE}`,
`node ${VUE_CLI_PATH} build --target lib --dest ${buildFolder} --name themeBundle ${DEV_VUE_THEME_ENTRY_FILE}`,
{
cwd: process.cwd(),
env: {
Expand Down Expand Up @@ -125,10 +163,11 @@ export function devBuild({ buildFolder, imageCdnUrl, isProd }: DevBuild) {
export async function devReactBuild({
buildFolder,
runOnLocal,
assetBasePath,
assetBasePath = '',
localThemePort,
imageCdnUrl,
isHMREnabled,
targetDirectory
}: DevReactBuild): Promise<MultiStats> {
const buildPath = path.join(process.cwd(), buildFolder);
try {
Expand All @@ -145,7 +184,6 @@ export async function devReactBuild({
themeWebpackConfigPath
));
}

const ctx = {
buildPath: buildPath,
NODE_ENV: (!runOnLocal && 'production') || 'development',
Expand All @@ -154,15 +192,39 @@ export async function devReactBuild({
localThemePort: localThemePort,
context: process.cwd(),
isHMREnabled,
targetDirectory
};
const baseWebpackConfig = createBaseWebpackConfig(
ctx,
webpackConfigFromTheme,
);
const assetNormalizedBasePath =
assetBasePath[assetBasePath.length - 1] === '/'
? assetBasePath
: assetBasePath + '/';
return new Promise((resolve, reject) => {
if(!runOnLocal) {
fs.stat(path.resolve((targetDirectory || process.cwd()), CDN_ENTRY_FILE), function (err, stat) {
if (err == null) {
//deleting file if exist
fs.unlink(path.resolve((targetDirectory || process.cwd()), CDN_ENTRY_FILE), function (err) {
if (err) return console.log(err);
Logger.debug(' \n Existing file deleted successfully');
});
}
fs.appendFileSync(path.resolve((targetDirectory || process.cwd()), CDN_ENTRY_FILE), dynamicCDNScript({assetNormalizedBasePath, vueJs: false }));

});
}
webpack(baseWebpackConfig, (err, stats) => {
console.log(err);
console.log(stats.toString());
if(!runOnLocal) {
fs.unlink(path.resolve((targetDirectory || process.cwd()), CDN_ENTRY_FILE), function (err) {
if (err) return console.log(err);
Logger.debug(' \n file deleted successfully');
});
}
if (err || stats.hasErrors()) {
reject();
}
Expand Down
2 changes: 1 addition & 1 deletion src/helper/serve.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export async function startServer({ domain, host, isSSR, port }) {
'fdk-cli-dev-files',
User.current_user._id,
)
).start.cdn.url;
).complete.cdn.url;
} else {
jetfireUrl.searchParams.set('__csr', 'true');
}
Expand Down
22 changes: 12 additions & 10 deletions src/helper/theme.react.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import path from "path"
import TerserPlugin from 'terser-webpack-plugin';
import webpack, { Configuration } from 'webpack';
import { mergeWithRules, merge } from 'webpack-merge';
import { getLocalBaseUrl } from './serve.utils';
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
import { CDN_ENTRY_FILE } from './build';
const context = process.cwd();

const baseConfig = (configOptions) => {
const {
Expand All @@ -15,7 +18,6 @@ const baseConfig = (configOptions) => {

return {
mode: isLocal ? 'development' : 'production',

devtool: isLocal ? 'source-map' : false,
optimization: {
minimizer: [
Expand Down Expand Up @@ -83,6 +85,7 @@ export default (ctx, extendedWebpackConfig): Configuration[] => {
imageCdnUrl = '',
localThemePort = 5500,
isHMREnabled = true,
targetDirectory
} = ctx;

const assetNormalizedBasePath =
Expand All @@ -109,7 +112,6 @@ export default (ctx, extendedWebpackConfig): Configuration[] => {
};
const baseWebpackConfig = baseConfig(configOptions);
const extendedWebpackResolved = extendedWebpackConfig(configOptions);

const mergedBaseConfig: Configuration = mergeWithRules({
module: {
rules: {
Expand All @@ -120,14 +122,14 @@ export default (ctx, extendedWebpackConfig): Configuration[] => {
})(extendedWebpackResolved, baseWebpackConfig);

if (mergedBaseConfig.entry.hasOwnProperty('themeBundle')) {
mergedBaseConfig.entry['themeBundle'] =
isLocal && isHMREnabled
? [
require.resolve('webpack-hot-middleware/client'),
...mergedBaseConfig.entry['themeBundle'],
]
: mergedBaseConfig.entry['themeBundle'];
let entryPoints = [...mergedBaseConfig.entry['themeBundle']];
if (isLocal && isHMREnabled) {
entryPoints.unshift(require.resolve('webpack-hot-middleware/client'));
} else if (!isLocal) {
entryPoints.unshift(path.resolve(targetDirectory || context, CDN_ENTRY_FILE));
}
mergedBaseConfig.entry['themeBundle'] = entryPoints;
}

return [mergedBaseConfig];
};
5 changes: 0 additions & 5 deletions src/lib/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,11 @@ export const startServer = async () => {
return Auth.server;
};

async function checkVersionCompatibility() {
const response = await ThemeService.checkCompatibleVersion();
}

export default class Auth {
static server = null;
static isOrganizationChange = false;
constructor() {}
public static async login() {
await checkVersionCompatibility();
Logger.info(
chalk.green(
'Current env: ',
Expand Down
5 changes: 0 additions & 5 deletions src/lib/CommandError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ export const ErrorCodes = {
`No themes are created, Please create/add a theme under the sales channel. For more details, refer to the documentation link: ${domain}/help/docs/partners/themes/vuejs/overview`,
code: 'FDK-00011',
},
DOWNGRADE_CLI_VERSION: {
message:
'Seems like current Fynd Platform version is not compatible with installed CLI version.\n\nIn order to continue with current FP version, Please use previous version of CLI `npm install -g @gofynd/fdk-cli@3.0.4` command.',
code: 'FDK-00012',
},

// generic
ECONN_RESET: {
Expand Down
Loading
Loading