Skip to content

Commit 0296873

Browse files
committed
Adding Pckgd readme and installer
1 parent 619ecb8 commit 0296873

3 files changed

Lines changed: 93 additions & 0 deletions

File tree

Pckgd/Install.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This script adds Pckgd to the MorningBatch and ScheduledTask files, allowing automatic updates.
2+
3+
global model, Data, q
4+
5+
batchContent = model.PythonContent('MorningBatch')
6+
if '''model.CallScript("Pckgd")''' not in batchContent and '''model.CallScript('Pckgd')''' not in batchContent:
7+
batchContent = batchContent + '''\n\nData.pckgdCaller = "MorningBatch"\nmodel.CallScript("Pckgd")'''
8+
model.WriteContentPython("MorningBatch", batchContent)
9+
10+
scheduledTasks = model.TextContent('ScheduledTasks')
11+
if '''model.CallScript("Pckgd")''' not in batchContent and '''model.CallScript('Pckgd')''' not in batchContent:
12+
batchContent = batchContent + '''\n\nData.pckgdCaller = "ScheduledTasks"\nmodel.CallScript("Pckgd")'''
13+
model.WriteContentPython("ScheduledTasks", batchContent)
14+
15+
print("REDIRECT=/PyScript/Pckgd?c=installed")

Pckgd/README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Pckgd
2+
3+
Pckgd (pronounced "packaged") is a lightweight package manager for projects build upon TouchPoint's Python and SQL
4+
capabilities with less complexity than manually managing files in the Special Content area.
5+
6+
## Installation
7+
1. Download the Pckgd zip file from [the releases](https://github.com/TenthPres/TouchPointScripts/releases) and upload the whole zip file to
8+
`mychurch.tpsdb.com/InstallPyScriptProject`. This will install the script.
9+
2. Navigate to `mychurch.tpsdb.com/PyScript/Pckgd` to get started. Scripts that you have manually installed before
10+
installing Pckgd are likely missing the special required headers that Pckgd needs to identify them as packages,
11+
which means you may need to manually update them in Special Content one more time.
12+
13+
## Documentation for Package Developers
14+
15+
Packages are identified with a simple set of comments included in the script file, called 'headers.' The headers must
16+
be located in the first 100 lines of the script, and must be located immediately together. If a "stop editing"
17+
demarcation is used (explained below), the headers must be *above* the demarcation.
18+
The headers are:
19+
20+
- `# Pckgd` - Required. No value. Identifies the file as part of a Pckgd package. Without this header, the script won't be found in
21+
the query for packages.
22+
- `# Updates from:` - Required for updates. An identifier of where updates should come from. Two types of values are allowed:
23+
- A URL to a text file: e.g. `# Updates from: https://example.com/mypackage-latest.txt`
24+
- A GitHub repository in the format `GitHub/username/repo/path/to/file.py`: e.g. `# Updates from: GitHub/TenthPres/TouchPointScripts/Pckgd/Pckgd.py`
25+
- `# Title:` - Optional, but recommended. The human-readable name of the package. This is the name shown in the UI.
26+
- `# Description:` - Optional, but recommended. A brief description of what the package does.
27+
- `# Depends on:` - Optional. A comma-separated list of other Pckgd scripts (with extensions) that this script depends
28+
on. For example, if a python script depends on a SQL file, this header might be something like `# Depends on: MyScript.sql`.
29+
When dependencies are defined, they will be provided as part of installation, provided they are available in the same
30+
source and directory as the current file.
31+
- `# Version` - Optional. The current version of the script. If not provided, a hash will be generated on a per-file basis to determine if a new version is available.
32+
- `# License:` - Optional. The license under which the package is provided.
33+
- `# Author:` - Optional. The author of the package.
34+
- `# Header color:` - Optional. A hex color code (e.g. `#FF0000`) to use as the header color in the UI. If one is not provided, a color is generated from a hash of the file name.
35+
- `# Header image:` - Optional. A URL to an image to use as the header image in the UI.
36+
37+
### Examples
38+
39+
A well-documented python file with a few dependencies may have a headers like this:
40+
```python
41+
# Pckgd
42+
# Updates from: GitHub/TenthPres/TouchPointScripts/SamplePackage/MyPackage.py
43+
# Title: My Package
44+
# Description: This package does something useful.
45+
# Depends on: SomeDependency.sql, AnotherDependency.py
46+
# Version: 1.0.0
47+
# License: MIT
48+
```
49+
50+
A minimally-documented SQL file may have headers like this:
51+
```sql
52+
-- Pckgd
53+
-- Updates from: https://example.com/mypackage-latest.sql
54+
```
55+
56+
### "Stop editing" demarcation
57+
58+
Some scripts may require that some variables or constants be set for the script to work properly, particularly to
59+
adapt the script to the specific needs of a given church. These variables must be near the top of the script, and
60+
should be separated from the rest of the script with a "stop editing" demarcation, like this:
61+
62+
```python
63+
# ========== DO NOT EDIT BELOW THIS POINT ==========
64+
```
65+
66+
This is crucial for two reasons:
67+
1. When packages are installed, only content below this line will be replaced. This allows for customizations to be
68+
preserved.
69+
2. When files are evaluated to see if updates are needed, only the content below this line is considered. This allows
70+
for customizations to exist and also not interfere with update detection.
71+
72+
If a script does not have any customizations or provides though customizations through a UI, you do not need to include
73+
a demarcation.

gulpfile.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ function buildEverything(cb) {
1818
.pipe(zip('NonweeklyMeetings.zip'))
1919
.pipe(gulp.dest('.Builds'));
2020

21+
// Pckgd Installer
22+
gulp.src(['Pckgd/*.py', "Pckgd/keyword"])
23+
.pipe(zip('Pckgd.zip'))
24+
.pipe(gulp.dest('.Builds'));
25+
2126
cb();
2227
}
2328

0 commit comments

Comments
 (0)