Skip to content

Commit

Permalink
Merge pull request #34 from jwanner83/#33-fix-required-localization
Browse files Browse the repository at this point in the history
#33 fix required localization
  • Loading branch information
jwanner83 authored Apr 26, 2022
2 parents 9cf2e2e + 93a4de7 commit ac43cbb
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion bundler/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "liferay-npm-bundler-improved",
"description": "A highly experimental and non-official module which bundles the javascript into the liferay loader and creates a jar file.",
"version": "1.0.3",
"version": "1.0.4",
"author": "Jonas Wanner",
"license": "ISC",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions bundler/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { getBabelOutputPlugin } from '@rollup/plugin-babel'
import commonjs from '@rollup/plugin-commonjs'
import eslint from '@rollup/plugin-eslint'
import json from '@rollup/plugin-json'
import { RollupOptions } from 'rollup'
import copy from 'rollup-plugin-copy'
import esbuild from 'rollup-plugin-esbuild'
import { getBabelOutputPlugin } from '@rollup/plugin-babel'
import { preserveShebangs } from 'rollup-plugin-preserve-shebangs'
import { RollupOptions } from 'rollup'

const config: RollupOptions = {
input: 'src/mod.ts',
Expand Down
2 changes: 1 addition & 1 deletion bundler/src/handler/FeaturesHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { readFile } from 'fs'
import { promisify } from 'util'
import { sep } from 'path'
import { promisify } from 'util'
import npmbundlerrc from '../types/npmbundlerrc.types'
import Pack from '../types/Pack.types'

Expand Down
31 changes: 19 additions & 12 deletions bundler/src/handler/ProcessHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { access, copyFile, mkdir, readdir, readFile, rm } from 'fs'
import { promisify } from 'util'
import { sep } from 'path'
import { promisify } from 'util'
import { version } from '../../package.json'
import { log } from '../log'
import FeaturesHandler from './FeaturesHandler'
Expand Down Expand Up @@ -96,6 +96,11 @@ export default class ProcessHandler {
'language-resource',
',liferay.resource.bundle;resource.bundle.base.name="content.Language"'
)
} else {
manifestMFTemplate.replace(
'language-resource',
''
)
}

// process manifest.json
Expand All @@ -104,17 +109,6 @@ export default class ProcessHandler {
manifestJSONTemplate.replace('name', this.packageHandler.pack.name)
manifestJSONTemplate.replace('version', this.packageHandler.pack.version)

// process localization
if (this.featuresHandler.hasLocalization) {
const files = await promisify(readdir)(this.featuresHandler.localizationPath)
for (const file of files) {
this.jarHandler.archive.append(
(await promisify(readFile)(`${this.featuresHandler.localizationPath}${sep}${file}`)).toString(),
{ name: `/content/${file}` }
)
}
}

// process jar file
this.jarHandler.archive.append(manifestMFTemplate.processed, {
name: `/META-INF/${manifestMFTemplate.name}`
Expand All @@ -128,6 +122,19 @@ export default class ProcessHandler {
this.jarHandler.archive.append(JSON.stringify(this.packageHandler.pack), {
name: `/META-INF/resources/package.json`
})

// process localization
if (this.featuresHandler.hasLocalization) {
const files = await promisify(readdir)(this.featuresHandler.localizationPath)
for (const file of files) {
this.jarHandler.archive.append(
(
await promisify(readFile)(`${this.featuresHandler.localizationPath}${sep}${file}`)
).toString(),
{ name: `/content/${file}` }
)
}
}
}

async create(): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion bundler/src/handler/TemplateHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { access, readFile } from 'fs'
import { promisify } from 'util'
import { sep } from 'path'
import { promisify } from 'util'
import TemplatesNotFoundException from '../exceptions/TemplatesNotFoundException'

export default class TemplateHandler {
Expand Down
5 changes: 2 additions & 3 deletions examples/plain/.npmbundlerrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"output-dir": "dist",
"features": {
"js-extender": true,
"web-context": "/plain",
"localization": "features/localization/Language"
"web-context": "/plain"
}
}
}
}
6 changes: 0 additions & 6 deletions examples/plain/features/localization/Language.properties

This file was deleted.

3 changes: 1 addition & 2 deletions examples/plain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"com.liferay.portlet.instanceable": true,
"javax.portlet.name": "plain",
"javax.portlet.display-name": "Plain",
"javax.portlet.security-role-ref": "power-user,user",
"javax.portlet.resource-bundle": "content.Language"
"javax.portlet.security-role-ref": "power-user,user"
},
"main": "index",
"devDependencies": {
Expand Down

0 comments on commit ac43cbb

Please sign in to comment.