Skip to content

Port the source code to CoffeeScript #23

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

Merged
merged 17 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
.* text

*.cjs text
*.coffee text
*.css text diff=css
*.html text diff=html
*.http text
*.hx text
*.hxml text
*.js text
*.json text
*.md text diff=markdown
Expand All @@ -21,7 +20,6 @@

*.ico binary
*.jpg binary
*.n binary
*.pdf binary
*.png binary
*.webp binary
Expand Down
14 changes: 2 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ jobs:
steps:
- name: Fetch sources
uses: actions/checkout@v4
- name: Set up Lix
uses: lix-pm/setup-lix@master
- name: Set up Node.js
uses: actions/setup-node@v4
with:
Expand All @@ -20,15 +18,7 @@ jobs:
coverage: none
extensions: curl, intl, mbstring, simplexml
php-version: latest
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/haxe
key: haxe-${{runner.os}}-lix-${{hashFiles('.haxerc', 'haxe_libraries/*.hxml')}}
restore-keys: haxe-${{runner.os}}-lix-
- name: Install dependencies
run: |
lix download
npm ci
run: npm ci
- name: Run tests
run: lix Test
run: node --run test
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
/**/.DS_Store
/.idea/
/bin/*.map
/lib/*.js
/lib/*.map
/lib/**/*.js
/lib/**/*.js.map
/node_modules/
/npm-debug.log
/res/
/run.n
/var/
/wiki/
4 changes: 0 additions & 4 deletions .haxerc

This file was deleted.

3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"recommendations": [
"bmewburn.vscode-intelephense-client",
"lix.lix",
"nadako.vshaxe"
"phil294.coffeesense"
]
}
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"editor.insertSpaces": false,
"editor.tabSize": 2,
"files.associations": {"Cakefile": "coffeescript"},
"files.encoding": "utf8",
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
Expand Down
46 changes: 46 additions & 0 deletions Cakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{spawnSync} = require "node:child_process"
{readdirSync, rmSync} = require "node:fs"
{join} = require "node:path"
{env} = require "node:process"
pkg = require "./package.json"

option "-m", "--map", "Whether to generate source maps."

task "build", "Builds the project.", (options) ->
sourcemaps = if options.map then ["--map"] else []
run "coffee", "--compile", sourcemaps..., "--no-header", "--output", "lib", "src"

task "clean", "Deletes all generated files.", ->
rmSync join("lib", file) for file in readdirSync "lib" when not file.endsWith ".d.ts"
rmSync join("var", file), recursive: yes for file in readdirSync "var" when file isnt ".gitkeep"

task "dist", "Packages the project.", ->
invoke "clean"
invoke "build"

task "lint", "Performs the static analysis of source code.", ->
npx "coffeelint", "--file=etc/coffeelint.json", "Cakefile", "example", "src", "test"

task "publish", "Publishes the package.", ->
invoke "dist"
run "npm", "publish", "--registry=#{registry}" for registry in ["https://registry.npmjs.org", "https://npm.pkg.github.com"]
run "git", action..., "v#{pkg.version}" for action in [["tag"], ["push", "origin"]]

task "test", "Runs the test suite.", ->
env.NODE_ENV = "test"
run "coffee", "--compile", "--map", "--no-header", "--output", "lib", "src", "test"
run "node", "--enable-source-maps", "--test", "--test-reporter=spec", "lib/**/*_test.js"

task "watch", "Watches for file changes.", (options) ->
sourcemaps = if options.map then ["--map"] else []
run "coffee", "--compile", sourcemaps..., "--no-header", "--output", "lib", "--watch", "src", "test"

# Executes a command from a local package.
npx = (command, args...) -> run "npm", "exec", "--", command, args...

# Spawns a new process using the specified command.
run = (command, args...) ->
{status} = spawnSync command, args, shell: yes, stdio: "inherit"
if status isnt 0
console.error "Command failed:", command, args...
process.exit status
2 changes: 1 addition & 1 deletion bin/php_minifier.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bin/php_minifier.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
Set-StrictMode -Version Latest

$file = "$PSScriptRoot/php_minifier.js"
if (Test-Path "$file.map") { node --enable-source-maps $file @args }
if (Test-Path "$PSScriptRoot/../lib/cli.js.map") { node --enable-source-maps $file @args }
else { node $file @args }
7 changes: 0 additions & 7 deletions build.hxml

This file was deleted.

73 changes: 0 additions & 73 deletions etc/checkstyle.json

This file was deleted.

28 changes: 28 additions & 0 deletions etc/coffeelint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"arrow_spacing": {"level": "error"},
"braces_spacing": {"level": "error"},
"bracket_spacing": {"level": "error"},
"colon_assignment_spacing": {"level": "error", "spacing": {"left": 0, "right": 1}},
"cyclomatic_complexity": {"level": "error"},
"ensure_comprehensions": {"level": "error"},
"eol_last": {"level": "error"},
"indentation": {"value": 1},
"max_line_length": {"value": 160},
"missing_parseint_radix": {"level": "error"},
"newlines_after_classes": {"level": "error", "value": 1},
"no_debugger": {"level": "error"},
"no_empty_functions": {"level": "error"},
"no_empty_param_list": {"level": "error"},
"no_interpolation_in_single_quotes": {"level": "error"},
"no_nested_string_interpolation": {"level": "error"},
"no_private_function_fat_arrows": {"level": "error"},
"no_spaces": {"level": "error"},
"no_tabs": {"level": "ignore"},
"no_this": {"level": "error"},
"no_unnecessary_fat_arrows": {"level": "error"},
"object_shorthand": {"level": "error"},
"prefer_english_operator": {"level": "error", "doubleNotLevel": "error"},
"space_operators": {"level": "error"},
"spacing_after_comma": {"level": "error", "ignore_elision": true},
"transform_messes_up_line_numbers": {"level": "error"}
}
17 changes: 0 additions & 17 deletions example/gulpfile.cjs

This file was deleted.

15 changes: 15 additions & 0 deletions example/gulpfile.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {phpMinify} from "@cedx/php-minifier"
import gulp from "gulp"
import process from "node:process"

# Compresses a given set of PHP scripts.
export compressPhp = ->
isWindows = process.platform is "win32"
options =
binary: if isWindows then "C:/Program Files/PHP/php.exe" else "/usr/bin/php"
mode: if isWindows then "safe" else "fast"
silent: process.stdout.isTTY

gulp.src "path/to/**/*.php", read: false
.pipe phpMinify options
.pipe gulp.dest "path/to/out"
File renamed without changes.
3 changes: 0 additions & 3 deletions haxe_libraries/ansi.hxml

This file was deleted.

6 changes: 0 additions & 6 deletions haxe_libraries/asys.hxml

This file was deleted.

4 changes: 0 additions & 4 deletions haxe_libraries/checkstyle.hxml

This file was deleted.

3 changes: 0 additions & 3 deletions haxe_libraries/http-status.hxml

This file was deleted.

7 changes: 0 additions & 7 deletions haxe_libraries/hxnodejs.hxml

This file was deleted.

3 changes: 0 additions & 3 deletions haxe_libraries/tink_chunk.hxml

This file was deleted.

8 changes: 0 additions & 8 deletions haxe_libraries/tink_cli.hxml

This file was deleted.

3 changes: 0 additions & 3 deletions haxe_libraries/tink_core.hxml

This file was deleted.

6 changes: 0 additions & 6 deletions haxe_libraries/tink_http.hxml

This file was deleted.

5 changes: 0 additions & 5 deletions haxe_libraries/tink_io.hxml

This file was deleted.

4 changes: 0 additions & 4 deletions haxe_libraries/tink_macro.hxml

This file was deleted.

3 changes: 0 additions & 3 deletions haxe_libraries/tink_priority.hxml

This file was deleted.

5 changes: 0 additions & 5 deletions haxe_libraries/tink_querystring.hxml

This file was deleted.

6 changes: 0 additions & 6 deletions haxe_libraries/tink_streams.hxml

This file was deleted.

4 changes: 0 additions & 4 deletions haxe_libraries/tink_stringly.hxml

This file was deleted.

6 changes: 0 additions & 6 deletions haxe_libraries/tink_syntaxhub.hxml

This file was deleted.

7 changes: 0 additions & 7 deletions haxe_libraries/tink_testrunner.hxml

This file was deleted.

4 changes: 0 additions & 4 deletions haxe_libraries/tink_typecrawler.hxml

This file was deleted.

Loading