Skip to content

Commit 308d902

Browse files
authored
Merge pull request #246 from devforth/improving-win-installation-speed
fix: update package.json template to use dynamic adminforth version a…
2 parents 917d897 + 51964cc commit 308d902

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

adminforth/commands/createApp/templates/package.json.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"dependencies": {
2424
"@dotenvx/dotenvx": "^1.34.0",
25-
"adminforth": "latest",
25+
"adminforth": "{{adminforthVersion}}",
2626
"express": "latest-4"
2727
},
2828
"devDependencies": {

adminforth/commands/createApp/utils.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ import { promisify } from 'util';
1414

1515
const execAsync = promisify(exec);
1616

17+
function detectAdminforthVersion() {
18+
const userAgent = process.env.npm_config_user_agent || '';
19+
if (userAgent.includes('adminforth@next')) {
20+
return 'next'
21+
};
22+
return 'main';
23+
}
24+
25+
1726
export function parseArgumentsIntoOptions(rawArgs) {
1827
const args = arg(
1928
{
@@ -58,6 +67,7 @@ export async function promptForMissingOptions(options) {
5867
...options,
5968
appName: options.appName || answers.appName,
6069
db: options.db || answers.db,
70+
adminforthVersion: detectAdminforthVersion(),
6171
};
6272
}
6373

@@ -203,7 +213,10 @@ async function writeTemplateFiles(dirname, cwd, options) {
203213
{
204214
src: 'package.json.hbs',
205215
dest: 'package.json',
206-
data: { appName },
216+
data: {
217+
appName,
218+
adminforthVersion: options.adminforthVersion || 'latest'
219+
},
207220
},
208221
{
209222
src: 'index.ts.hbs',

adminforth/modules/codeInjector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ class CodeInjector implements ICodeInjector {
345345
await fsExtra.copy(spaDir, this.spaTmpPath(), {
346346
filter: (src) => {
347347
// /adminforth/* used for local development and /dist/* used for production
348-
const filterPasses = !src.includes('/adminforth/spa/node_modules') && !src.includes('/adminforth/spa/dist')
349-
&& !src.includes('/dist/spa/node_modules') && !src.includes('/dist/spa/dist');
348+
const filterPasses = !src.includes(`${path.sep}adminforth${path.sep}spa${path.sep}node_modules`) && !src.includes(`${path.sep}adminforth${path.sep}spa${path.sep}dist`)
349+
&& !src.includes(`${path.sep}dist${path.sep}spa${path.sep}node_modules`) && !src.includes(`${path.sep}dist${path.sep}spa${path.sep}dist`);
350350
if (process.env.HEAVY_DEBUG && !filterPasses) {
351351
console.log('🪲⚙️ fsExtra.copy filtered out', src);
352352
}

0 commit comments

Comments
 (0)