Skip to content

Add more Scratch projects for Experience CS #538

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 5 commits into from
May 1, 2025
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
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
web: bundle exec puma -C config/puma.rb
release: bundle exec rails db:migrate && bundle exec rake projects:create_experience_cs_example
release: bundle exec rails db:migrate && bundle exec rake projects:create_experience_cs_examples
worker: bundle exec good_job start --max-threads=8
56 changes: 41 additions & 15 deletions lib/tasks/projects.rake
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,47 @@ namespace :projects do
FilesystemProject.import_all!
end

desc "Create example Scratch project for Experience CS (if it doesn't already exist)"
task create_experience_cs_example: :environment do
attributes = {
identifier: 'experience-cs-example',
locale: 'en',
project_type: Project::Types::SCRATCH,
name: 'Experience CS Example',
user_id: nil
}
if Project.unscoped.exists?(attributes.slice(:identifier, :locale))
puts 'Scratch project already exists'
elsif Project.create(attributes)
puts 'Scratch project created successfully'
else
puts 'Scratch project creation failed'
desc "Create example Scratch projects for Experience CS (if they don't already exist)"
task create_experience_cs_examples: :environment do
projects = [
{
identifier: 'experience-cs-example',
locale: 'en',
project_type: Project::Types::SCRATCH,
name: 'Experience CS Example',
user_id: nil
},
{
identifier: 'dialogue-in-scratch',
locale: 'en',
project_type: Project::Types::SCRATCH,
name: 'Dialogue in Scratch',
user_id: nil
},
{
identifier: 'ten-block-mission',
locale: 'en',
project_type: Project::Types::SCRATCH,
name: '10 Block Mission',
user_id: nil
},
{
identifier: 'blank-scratch-starter',
locale: 'en',
project_type: Project::Types::SCRATCH,
name: 'Blank Scratch Starter',
user_id: nil
}
]
projects.each do |attributes|
identifier = attributes[:identifier]
if Project.unscoped.exists?(attributes.slice(:identifier, :locale))
puts "Scratch project with identifier '#{identifier}' already exists"
elsif Project.create(attributes)
puts "Scratch project with identifier '#{identifier}' created successfully"
else
puts "Scratch project with identifier '#{identifier}' creation failed"
end
end
end
end