Skip to content

Commit d01a832

Browse files
committed
nambahin docker dkk
1 parent 4867a24 commit d01a832

File tree

5 files changed

+91
-7
lines changed

5 files changed

+91
-7
lines changed

.dockerignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
node_modules
2+
npm-debug.log
3+
.git
4+
.gitignore
5+
.env
6+
.env.*
7+
.DS_Store
8+
coverage
9+
.nyc_output
10+
.vscode
11+
.idea
12+
*.swp
13+
*.swo
14+
*~
15+
*.log
16+
test
17+
tests
18+
__tests__
19+
*.test.js
20+
*.spec.js
21+
README.md
22+
CONTRIBUTING.md
23+
LICENSE
24+
.github
25+
.eslintrc.js
26+
.prettierrc
27+
docker-compose.yml
28+
Dockerfile*
29+
formalized/
30+
mappings_*.json
31+
formal_*.txt

docker-compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: '3.8'
2+
services:
3+
formalizer-cli:
4+
build: .
5+
image: id-auto-formalizer:latest
6+
container_name: formalizer-cli
7+
stdin_open: true
8+
tty: true

dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Dockerfile
2+
FROM node:18-alpine AS builder
3+
4+
# Set working directory
5+
WORKDIR /app
6+
7+
# Copy package files
8+
COPY package*.json ./
9+
10+
# Install dependencies
11+
RUN npm ci --only=production
12+
13+
# Copy source code
14+
COPY src/ ./src/
15+
COPY README.md ./
16+
COPY LICENSE ./
17+
18+
# Create a minimal production image
19+
FROM node:18-alpine
20+
21+
WORKDIR /app
22+
23+
# Copy from builder
24+
COPY --from=builder /app ./
25+
26+
# Create non-root user
27+
RUN addgroup -g 1001 -S nodejs && \
28+
adduser -S nodejs -u 1001
29+
30+
# Change ownership
31+
RUN chown -R nodejs:nodejs /app
32+
33+
# Switch to non-root user
34+
USER nodejs
35+
36+
# Expose port (if adding web server later)
37+
EXPOSE 3000
38+
39+
# Default command for CLI
40+
ENTRYPOINT ["node", "src/cli.js"]

examples/demo.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Contoh penggunaan Bahasa Indonesia Auto Formalizer
21
const IndonesianFormalizer = require('../src/index');
32
const chalk = require('chalk');
43

examples/integration.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ const vscode = {
150150
}
151151
},
152152
window: {
153-
showInformationMessage: (msg) => console.log(`Info: ${msg}`),
153+
showInformationMessage: msg => console.log(`Info: ${msg}`),
154154
activeTextEditor: {
155155
document: { getText: () => 'mock text' },
156-
edit: (editBuilder) => { }
156+
edit: editBuilder => { }
157157
}
158158
}
159159
};
@@ -172,6 +172,7 @@ vscode.commands.registerCommand('indonesian-formalizer.formalizeSelection', () =
172172
editBuilder.replace(selection, formal);
173173
});
174174

175+
// eslint-disable-next-line no-undef
175176
vscode.window.showInformationMessage(`Text formalized! Score: ${analysis.score}%`);
176177
});
177178

@@ -198,7 +199,7 @@ const FormalizerComponent = () => {
198199
React.createElement('h2', null, '🇮🇩 Indonesian Text Formalizer'),
199200
React.createElement('textarea', {
200201
value: text,
201-
onChange: (e) => setText(e.target.value),
202+
onChange: e => setText(e.target.value),
202203
placeholder: 'Ketik teks informal di sini...'
203204
}),
204205
React.createElement('button', { onClick: handleFormalize }, 'Formalize'),
@@ -232,13 +233,13 @@ function formalizeGitCommit() {
232233
output: process.stdout
233234
});
234235

235-
readline.question('Commit message (informal): ', (casualMessage) => {
236+
readline.question('Commit message (informal): ', casualMessage => {
236237
const formalMessage = formalizer.formalize(casualMessage);
237238

238239
console.log(`\nOriginal: ${casualMessage}`);
239240
console.log(`Formal: ${formalMessage}`);
240241

241-
readline.question('\nUse formal version? (y/n): ', (answer) => {
242+
readline.question('\nUse formal version? (y/n): ', answer => {
242243
const message = answer.toLowerCase() === 'y' ? formalMessage : casualMessage;
243244

244245
try {
@@ -271,6 +272,7 @@ async function handleSlackMessage(event) {
271272
type: 'section',
272273
text: {
273274
type: 'mrkdwn',
275+
// eslint-disable-next-line max-len
274276
text: `*Original:* ${text}\n*Formal:* ${formal}\n*Formality Score:* ${analysis.score}% (${analysis.level})`
275277
}
276278
}
@@ -289,10 +291,12 @@ async function handleSlackMessage(event) {
289291
const browserExtension = {
290292
// Fungsi untuk browser extension
291293
formalizeTextarea: function () {
294+
// eslint-disable-next-line no-undef
292295
const textareas = document.querySelectorAll('textarea');
293296

294297
textareas.forEach(textarea => {
295298
// Add formalize button
299+
// eslint-disable-next-line no-undef
296300
const button = document.createElement('button');
297301
button.textContent = 'Formalize';
298302
button.style.cssText = 'position: absolute; right: 5px; top: 5px; z-index: 1000;';
@@ -301,13 +305,15 @@ const browserExtension = {
301305
const formalizer = new IndonesianFormalizer();
302306
const formal = formalizer.formalize(textarea.value);
303307

308+
// eslint-disable-next-line max-len, no-undef
304309
if (confirm(`Replace with formal version?\n\nOriginal: ${textarea.value}\n\nFormal: ${formal}`)) {
305310
textarea.value = formal;
306311
textarea.dispatchEvent(new Event('input', { bubbles: true }));
307312
}
308313
});
309314

310315
// Position button relative to textarea
316+
// eslint-disable-next-line no-undef
311317
const wrapper = document.createElement('div');
312318
wrapper.style.position = 'relative';
313319
textarea.parentNode.insertBefore(wrapper, textarea);
@@ -337,7 +343,7 @@ _Skor formalitas: ${analysis.score}% (${analysis.level})_
337343
`;
338344

339345
// Send response via WhatsApp API
340-
await sendWhatsAppMessage(from, response);
346+
await handleWhatsAppMessage(from, response);
341347
}
342348
}
343349

0 commit comments

Comments
 (0)