sqlpkg 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ba14bd48fabc5204acf5de9c6531867fbd3fdd235af9512937e04973705c7b8
4
- data.tar.gz: 2a89534503c41d89b5e1dc4bbc4c24253b28ede109dd6e80c63a0339cffad4c3
3
+ metadata.gz: b0c9c714e0a4480503fadf4f5d9cd654478c4c10ba5bdfde03035e86543eeb7c
4
+ data.tar.gz: af68d8822b52b10f5aa3f435bf93aafa0e59d8e10544d20187ed4b587f89f14e
5
5
  SHA512:
6
- metadata.gz: dfa57df77c905f939e5674ddfbb838efe62c2737cc86274517f022b1a75e932c5b864efc77eae0b5b1f38748aba1a64f7f53cdb1867cc1da3424c13d3939e059
7
- data.tar.gz: b076a1665433c47fe8462c42e17ab522e951ad904e5e956b57965d7b4079e7aa43a943fad1325446fc52bb7f2076ab9f73402587f60cdb00c6bba6f72c541e39
6
+ metadata.gz: c432fe870d61eac54cfcfdf8341d04fb6d54af239f8595b8c61771d881f38596e6b1d868dd3f596f50652655f47ce8ab6fd3a62016e5a5da73af2efd51cde5fb
7
+ data.tar.gz: 3f2bc354e84debdd142eba7a86f0cdc2d6ce00e77a258604cd92138eeb89d09816e45d60c7e96629fd26943dda1eb8cccefc581f42983787500fb40736ca2ad3
data/README.md CHANGED
@@ -1,24 +1,78 @@
1
1
  # sqlpkg-ruby
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sqlpkg`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [sqlpkg](https://sqlpkg.org/) is the (unofficial) SQLite package registry. This gem provides a Ruby interface to [its CLI](https://github.com/nalgeon/sqlpkg-cli).
6
4
 
7
5
  ## Installation
8
6
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
7
  Install the gem and add to the application's Gemfile by executing:
12
8
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
9
+ $ bundle add sqlpkg
14
10
 
15
11
  If bundler is not being used to manage dependencies, install the gem by executing:
16
12
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
13
+ $ gem install sqlpkg
14
+
15
+ After installing the gem, run the installer:
16
+
17
+ $ rails generate sqlpkg:install
18
+
19
+ The installer does three things:
20
+
21
+ 1. creates an empty `.sqlpkg/` directory, which ensures that `sqlpkg` will run in "project scope" and not "global scope" (see [the `sqlpkg-cli` README](https://github.com/nalgeon/sqlpkg-cli#project-vs-global-scope) for more information)
22
+ 2. creates an empty `sqlpkg.lock` file, which `sqlpkg` will use to store information about the installed packages (see [the `sqlpkg-cli` README](https://github.com/nalgeon/sqlpkg-cli#lockfile) for more information)
23
+ 3. creates an initializer file at `config/initializers/sqlpkg.rb` which will patch the `SQLite3Adapter` to automatically load the extensions installed in the `.sqlpkg/` directory whenever the database is opened
24
+
25
+ Once properly integrated into your Rails application, you can install any extension listed on [the `sqlpkg` registry](https://sqlpkg.org/all/) by executing:
26
+
27
+ $ bundle exec sqlpkg install PACKAGE_IDENTIFIER
28
+
29
+ When exploring the [the `sqlpkg` registry](https://sqlpkg.org/all/), the `PACKAGE_IDENTIFIER` needed to install an extension is the title found in the cards, always in `owner/name` format.
30
+
31
+ This gem wraps the standalone executable version of the [sqlpkg-cli](https://github.com/nalgeon/sqlpkg-cli#download-and-install-preferred-method). These executables are platform specific, so there are actually separate underlying gems per platform, but the correct gem will automatically be picked for your platform.
32
+
33
+ Supported platforms are:
34
+
35
+ * arm64-darwin (macos-arm64)
36
+ * x86_64-darwin (macos-x64)
37
+ * arm64-linux (linux-arm64)
38
+ * x86_64-linux (linux-x64)
39
+
40
+ ### Using a local installation of `sqlpkg`
41
+
42
+ If you are not able to use the vendored standalone executables (for example, if you're on an unsupported platform), you can use a local installation of the `sqlpkg` executable by setting an environment variable named `SQLPKG_INSTALL_DIR` to the directory containing the executable.
43
+
44
+ For example, if you've installed `sqlpkg` so that the executable is found at `/usr/local/bin/sqlpkg`, then you should set your environment variable like so:
45
+
46
+ ``` sh
47
+ SQLPKG_INSTALL_DIR=/usr/local/bin
48
+ ```
49
+
50
+ This also works with relative paths. If you've installed into your app's directory at `./.bin/sqlpkg`:
51
+
52
+ ``` sh
53
+ SQLPKG_INSTALL_DIR=.bin
54
+ ```
18
55
 
19
56
  ## Usage
20
57
 
21
- TODO: Write usage instructions here
58
+ ```shell
59
+ $ bundle exec sqlpkg help
60
+ ┌────────────────────────────────────────────────┐
61
+ │ sqlpkg is an SQLite package manager. │
62
+ │ Use it to install or update SQLite extensions. │
63
+ │ │
64
+ │ Commands: │
65
+ │ help Display help │
66
+ │ info Display package information │
67
+ │ init Init project scope │
68
+ │ install Install packages │
69
+ │ list List installed packages │
70
+ │ uninstall Uninstall package │
71
+ │ update Update installed packages │
72
+ │ version Display version │
73
+ │ which Display path to extension file │
74
+ └────────────────────────────────────────────────┘
75
+ ```
22
76
 
23
77
  ## Development
24
78
 
data/exe/sqlpkg CHANGED
@@ -1,13 +1,13 @@
1
1
  #! /usr/bin/env ruby
2
2
  # because rubygems shims assume a gem's executables are Ruby
3
3
 
4
- require "litestream/commands"
4
+ require "sqlpkg/commands"
5
5
 
6
6
  begin
7
- command = [Litestream::Commands.executable, *ARGV]
7
+ command = [Sqlpkg::Commands.executable, *ARGV]
8
8
  puts command.inspect
9
9
  exec(*command)
10
- rescue Litestream::Commands::UnsupportedPlatformException, Litestream::Commands::ExecutableNotFoundException => e
10
+ rescue Sqlpkg::Commands::UnsupportedPlatformException, Sqlpkg::Commands::ExecutableNotFoundException => e
11
11
  warn("ERROR: " + e.message)
12
12
  exit 1
13
13
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators/base"
4
+
5
+ module Sqlpkg
6
+ module Generators
7
+ class InstallGenerator < ::Rails::Generators::Base
8
+ source_root File.expand_path("templates", __dir__)
9
+
10
+ def ensure_sqlpkg_project_scope_directory
11
+ empty_directory ".sqlpkg"
12
+ end
13
+
14
+ def create_empty_sqlpkg_lockfile
15
+ create_file "sqlpkg.lock"
16
+ end
17
+
18
+ def copy_initializer_file
19
+ template "initializer.rb", "config/initializers/sqlpkg.rb"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ module SqlpkgLoader
2
+ def configure_connection
3
+ super
4
+
5
+ @raw_connection.enable_load_extension(true)
6
+ Dir.glob(".sqlpkg/**/*.{dll,so,dylib}") do |extension_path|
7
+ @raw_connection.load_extension(extension_path)
8
+ end
9
+ @raw_connection.enable_load_extension(false)
10
+ end
11
+ end
12
+
13
+ ActiveSupport.on_load(:active_record_sqlite3adapter) do
14
+ prepend SqlpkgLoader
15
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/railtie"
4
+
5
+ module Sqlpkg
6
+ class Railtie < ::Rails::Railtie
7
+ # Load the `sqlpkg:install` generator into the host Rails app
8
+ generators do
9
+ require_relative "generators/sqlpkg/install_generator"
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module Sqlpkg
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqlpkg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-20 00:00:00.000000000 Z
11
+ date: 2023-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  description:
28
56
  email:
29
57
  - stephen.margheim@gmail.com
@@ -38,6 +66,9 @@ files:
38
66
  - exe/sqlpkg
39
67
  - lib/sqlpkg.rb
40
68
  - lib/sqlpkg/commands.rb
69
+ - lib/sqlpkg/generators/sqlpkg/install_generator.rb
70
+ - lib/sqlpkg/generators/sqlpkg/templates/initializer.rb
71
+ - lib/sqlpkg/railtie.rb
41
72
  - lib/sqlpkg/upstream.rb
42
73
  - lib/sqlpkg/version.rb
43
74
  homepage: https://github.com/fractaledmind/sqlpkg-ruby